2016-08-09 32 views
-1

Ich fire eine Abfrage für Geräteobjekt, aber nach dem Feuer diese HQL-Abfrage automatisch Subchild (Geräteprofil) Details wie ich kann HQL fix mit .....Wenn ich 1 HQL-Abfrage (Gerät) feuern dann 51 mal es Kinder in vielen zu eins gefeuert werden, wie es zu beheben, hibernate5


com.zaxxer.hikari.hibernate.HikariConnectionProvider

 <property name="hibernate.hikari.dataSource.url">jdbc:mysql://localhost:3306/gpstracking?autoReconnect=true</property> 
     <property name="hibernate.hikari.dataSource.user">root</property> 
     <property name="hibernate.hikari.dataSource.password">root</property> 
     <property name="hibernate.hikari.dataSourceClassName">com.mysql.jdbc.jdbc2.optional.MysqlDataSource</property> 
     <property name="hibernate.hikari.maximumPoolSize">50</property> 
     <property name="hibernate.hikari.idleTimeout">30000</property> 
     <!-- <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> 
     <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/gpstracking?autoReconnect=true</property> 
     <property name="hibernate.connection.username">root</property> 
     <property name="hibernate.connection.password">root</property> --> 
     <property name="hibernate.use_sql_comments">true</property> 

       <property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property><!--org.hibernate.dialect.MySQLDialect--> 
     <property name="current_session_context_class">thread</property> 
     <property name="show_sql">true</property>     
     <!-- <mapping class="Model.ScheduleAlert" /> --> 

     <mapping resource="Model/ScheduleAlert.hbm.xml"/> 

     <mapping resource="Model/login.hbm.xml"/> 
     <mapping resource="Model/device.hbm.xml"/> 
     <mapping resource="Model/geopath.hbm.xml"/> 
     <mapping resource="Model/geopath_detail.hbm.xml"/> 
     <mapping resource="Model/DeviceImage.hbm.xml"/> 
     <mapping resource="Model/lastTrack.hbm.xml"/> 
     <mapping resource="Model/Gt06portrequest.hbm.xml"/> 
     <mapping resource="Model/history.hbm.xml"/> 
     <mapping resource="Model/historyzero.hbm.xml"/> 
     <mapping resource="Model/adminMaster.hbm.xml"/> 
     <mapping resource="Model/Message.hbm.xml"/> 
     <mapping resource="Model/PortRequests.hbm.xml"/> 
     <mapping resource="Model/PortParsers.hbm.xml"/> 
     <mapping resource="Model/Hostname.hbm.xml"/> 
     <mapping resource="Model/EmailTemplet.hbm.xml"/> 
     <mapping resource="Model/SelectedTemp.hbm.xml"/> 
     <mapping resource="Model/SancharnetUser.hbm.xml"/> 
     <mapping resource="Model/MessageTemplate.hbm.xml"/> 
     <mapping resource="Model/SelectedMsgTemp.hbm.xml"/> 
     <mapping resource="Model/Fence.hbm.xml"/> 
     <mapping resource="Model/FenceDevice.hbm.xml"/> 
     <mapping resource="Model/tag.hbm.xml"/> 
     <mapping resource="Model/tagtype.hbm.xml"/> 
     <mapping resource="Model/AlertMessages.hbm.xml"/> 
     <mapping resource="Model/MaxSpeed.hbm.xml"/> 
     <mapping resource="Model/alert/Alert.hbm.xml"/> 
     <mapping resource="Model/managerSettings.hbm.xml"/> 
     <mapping resource="Model/MobileParsers.hbm.xml"/> 
     <mapping resource="Model/SampleLivePath.hbm.xml"/> 
     <mapping resource="Model/managerMsgSettings.hbm.xml"/> 
     <mapping resource="Model/KMLFiles.hbm.xml"/> 
     <mapping resource="Model/DemoKmlFiles.hbm.xml"/> 
     <mapping resource="Model/DeviceGroup.hbm.xml"/> 
     <mapping resource="Model/AnalogData.hbm.xml"/> 
     <mapping resource="Model/PoiPoint.hbm.xml"/> 
     <mapping resource="Model/deviceprofile.hbm.xml"/> 
     <mapping resource="Model/DigitalInputAlert.hbm.xml"/> 
     <mapping resource="Model/AnalogInputAlert.hbm.xml"/> 
     <mapping resource="Model/POIAlert.hbm.xml"/> 
     <mapping resource="Model/OverConsumptionAlert.hbm.xml"/> 
     <mapping resource="Model/Devicemaster.hbm.xml"/> 
     <mapping resource="Model/analogdigitalparameter.hbm.xml"/> 
     <mapping resource="Model/ManagerReportMaster.hbm.xml"/> 
     <mapping resource="Model/ManagerReportChild.hbm.xml"/> 
     <mapping resource="Model/systemParameter.hbm.xml"/> 
     <mapping resource="Model/GeopathAlert.hbm.xml"/> 
     <mapping resource="Model/Drivermanage.hbm.xml"/> 
     <mapping resource="Model/Drivermaster.hbm.xml"/> 
     <mapping resource="Model/Usermaster.hbm.xml"/> 
     <mapping resource="Model/Useralocation.hbm.xml"/> 
     <mapping resource="Model/Kmllive.hbm.xml"/> 
     <mapping resource="Model/Payment.hbm.xml"/> 
     <mapping resource="Model/Locationdata.hbm.xml"/> 
     <mapping resource="Model/Alertallocationchild.hbm.xml"/> 
     <mapping resource="Model/Alertallocationmaster.hbm.xml"/> 
     <mapping resource="Model/Expiryreport.hbm.xml"/> 
     <mapping resource="Model/Imagedata.hbm.xml"/> 
     <mapping resource="Model/Convertedimg.hbm.xml"/> 
     <mapping resource="Model/Antitheftalert.hbm.xml"/> 
     <mapping resource="Model/OverStayAlert.hbm.xml"/> 
     <mapping resource="Model/Reseller.hbm.xml"/> 
     <mapping resource="Model/Client.hbm.xml"/> 
     <mapping resource="Model/RouteAlert.hbm.xml"/> 
     <mapping resource="Model/RouteMaster.hbm.xml"/>  
     <mapping resource="Model/Onediractionfencealert.hbm.xml"/>  
     <mapping resource="Model/LoginLog.hbm.xml"/>   
     <mapping resource="Model/MaintainanceMaster.hbm.xml"/>   
     <mapping resource="Model/MaintainanceType.hbm.xml"/>   
     <mapping resource="Model/BusScheduleMaster.hbm.xml"/>  
     <mapping resource="Model/Tcpcommand.hbm.xml"/> 
    </session-factory> 
</hibernate-configuration> 

device.hbm.xml

deviceprofile.hbm.xml

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> 
<hibernate-mapping> 
    <class lazy="false" name="Model.DeviceProfile" table="deviceprofile"> 
    <id column="ProfileId" name="profileId" type="java.lang.Integer"> 
     <generator class="increment"/> 
    </id> 
    <property column="ProfileName" index="idx_deviceprofile_profilename" length="50" name="profileName" type="java.lang.String"> 
     </property> 
    <property column="SystemDate" length="30" name="systemDate" type="java.util.Date"> 
     </property> 
    <property column="Odometer" length="15" name="odometer" type="java.lang.String"> 
     </property> 
    <property column="digital_1" length="15" name="digital1" type="java.lang.String"> 
     </property> 
    <property column="digital_1_inverse" name="digital1_inverse" type="java.lang.Boolean"> 
     </property> 
    <property column="digital_2" length="15" name="digital2" type="java.lang.String"> 
     </property> 
    <property column="digital_2_inverse" name="digital2_inverse" type="java.lang.Boolean"> 
     </property> 
    <property column="digital_3" length="15" name="digital3" type="java.lang.String"> 
     </property> 
    <property column="digital_3_inverse" name="digital3_inverse" type="java.lang.Boolean"> 
     </property> 
    <property column="digital_4" length="15" name="digital4" type="java.lang.String"> 
     </property> 
    <property column="digital_4_inverse" name="digital4_inverse" type="java.lang.Boolean"> 
     </property> 
    <property column="digital_5" length="15" name="digital5" type="java.lang.String"> 
     </property> 
    <property column="digital_5_inverse" name="digital5_inverse" type="java.lang.Boolean"> 
     </property> 
    <property column="analog_5" length="15" name="analog5" type="java.lang.String"> 
     </property> 
    <property column="analog_1_unit" length="15" name="analog1_unit" type="java.lang.String"> 
     </property> 
    <property column="analog_2_unit" length="15" name="analog2_unit" type="java.lang.String"> 
     </property> 
    <property column="analog_3_unit" length="15" name="analog3_unit" type="java.lang.String"> 
     </property> 
    <property column="analog_4_unit" length="15" name="analog4_unit" type="java.lang.String"> 
     </property> 
    <property column="analog_5_unit" length="15" name="analog5_unit" type="java.lang.String"> 
     </property> 
    <property column="analog_1_formula" length="25" name="analog1_formula" type="java.lang.String"> 
     </property> 
    <property column="analog_2_formula" length="25" name="analog2_formula" type="java.lang.String"> 
     </property> 
    <property column="analog_3_formula" length="25" name="analog3_formula" type="java.lang.String"> 
     </property> 
    <property column="analog_4_formula" length="25" name="analog4_formula" type="java.lang.String"> 
     </property> 
    <property column="analog_5_formula" length="25" name="analog5_formula" type="java.lang.String"> 
     </property> 
    <property column="GPSFormat" length="15" name="gpsformat" type="java.lang.String"> 
     </property> 
    <property column="Cummulative_Odometer" length="15" name="cummulativeOdometer" type="java.lang.String"> 
     </property> 
    <set cascade="all" inverse="true" name="analogdatas"> 
     <key column="profileId"/> 
     <one-to-many class="Model.Analogdata"/> 
    </set> 
    <set cascade="all" inverse="true" lazy="false" name="deviceMaster"> 
     <key column="profileId"/> 
     <one-to-many class="Model.device"/> 
    </set> 
    <many-to-one cascade="all" column="ManagerId" name="managerSettings2" update="false"> 
    </many-to-one> 
    </class> 
</hibernate-mapping> 

ich habe bereits dieses Projekt und DAO-Datei so getan bitte Lösung liefern .....

+0

Bitte klären Sie Problem (was Sie tun wollen) und ein minimales Beispiel bieten, will niemand lesen eine Textwand, nur um zu antworten. –

+0

Ich verstehe die Frage wirklich nicht. Könntest Du das erläutern? – Takarii

+0

gibt es viele zu eins-Beziehung zwischen Gerät und Geräteprofil Wenn ich eine Abfrage wie, session.createQuery ("von Gerät mit DeviceID =" + deviceId) .list() auslösen; so, nach dem Feuer diese Abfrage 51 Zeit andere Anfrage für sein subchild deviceprofile Feuer. –

Antwort

0

Bitte erläutern Sie richtig Ihre Frage. ändern deviceprofile.hbm.xml Viele-zu-Eins-Abbildung, wie unten und überprüfen, ob es helfen:

<many-to-one cascade="all" column="ManagerId" name="managerSettings2" update="false" lazy="true" fetch="select">