-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Many-to-Many Query doesn't find any rows
PostPosted: Fri Feb 06, 2004 12:54 am 
Newbie

Joined: Wed Dec 31, 2003 9:45 pm
Posts: 19
I have two many-to-many relationships in my example, and the first one does not find any of the linked data, while the second one in the same program works perfectly. When I run the offending query directly in the database, it does find a row in the database, but as listed below, Hibernate says that no rows were found for Room 109. The only change I made to get the query to run was to replace ? with '109'.

Any thoughts?

<class name="net.tripleTech.dao.RoomVO" table="RoomObject">
<id name="roomID" type="string" unsaved-value="null">
<column name="RoomID" sql-type="varchar(100)" not-null="true"/>
<generator class="assigned"/>
</id>
<property name="buildingID"/>
<property name="plantID"/>
<property name="roomShortDescription"/>
<property name="roomLongDescription"/>
<property name="score"/>
<property name="lowTCPLimit"/>
<property name="highTCPLimit"/>
<property name="lowTCPLimitNoSuppression"/>
<property name="highTCPLimitNoSuppression"/>
<set name="detectionGroups" table="DetectionGroupRoomLink" cascade="save-update">
<key column="RoomID"/>
<many-to-many column="DetectionGroupID" class="net.tripleTech.dao.DetectionGroupVO"/>
</set>
<set name="suppression" table="SuppressionRoomLink" cascade="save-update">
<key column="RoomID"/>
<many-to-many column="SuppressionID" class="net.tripleTech.dao.SuppressionVO"/>
</set>

<set name="fireWatches" table="RoomFireWatchLink" cascade="save-update">
<key column="RoomID"/>
<many-to-many column="FireWatchID" class="net.tripleTech.dao.FireWatchVO"/>
</set>
<set name="barriers" table="BarrierRoomLink" cascade="save-update">
<key column="RoomID"/>
<many-to-many column="BarrierID" class="net.tripleTech.dao.BarrierVO"/>
</set>
<set name="barrierImpairments" table="BarrierRoomLink" cascade="save-update">
<key column="RoomID"/>
<many-to-many column="BarrierID" class="net.tripleTech.dao.ImpairmentBarrierVO"/>
</set>

<set name="suppressionImpairments" table="SuppressionRoomLink" cascade="save-update">
<key column="RoomID"/>
<many-to-many column="SuppressionID" class="net.tripleTech.dao.ImpairmentSuppressionVO"/>
</set>
<set name="detectors" table="detectionRoomView" inverse="true" cascade="none" >
<key column="RoomID"/>
<many-to-many column="DetectionID" class="net.tripleTech.dao.DetectionVO"/>
</set>
<set name="detectionImpairments" table="ImpairmentDetectionRoomView" inverse="true" cascade="none" >
<key column="RoomID"/>
<many-to-many column="ImpairmentID" class="net.tripleTech.dao.ImpairmentDetectionVO"/>
</set>
<set name="fireWatchRules" >
<key column = "RoomID"/>
<one-to-many class = "net.tripleTech.dao.FireWatchRuleLookupVO"/>
</set>

</class>




<class name="net.tripleTech.dao.BarrierVO" table="BarrierLookup">
<id name="barrierID" type="string" unsaved-value="null">
<column name="BarrierID" sql-type="varchar(100)" not-null="true"/>
<generator class="assigned"/>
</id>
<property name="barrierName"/>
<property name="appendix"/>
<property name="subComponentTypeID"/>
<property name="componentStatusID"/>
<set name="rooms" table="BarrierRoomLink">
<key column="BarrierID"/>
<many-to-many column="RoomID" class="net.tripleTech.dao.RoomVO"/>
</set>
</class>



2004-02-05 23:17:34,505 [Thread-4] DEBUG net.sf.hibernate.impl.SessionImpl - initializing collection [net.tripleTech.dao.RoomVO.barriers#109 ]
2004-02-05 23:17:34,505 [Thread-4] DEBUG net.sf.hibernate.impl.BatcherImpl - about to open: 0 open PreparedStatements, 0 open ResultSets
2004-02-05 23:17:34,505 [Thread-4] DEBUG net.sf.hibernate.impl.BatcherImpl - prepared statement get: select barrierr0_.BarrierID as BarrierID__, barrierr0_.RoomID as RoomID__, barrierv1_.BarrierID as BarrierID0_, barrierv1_.barrierName as barrierN2_0_, barrierv1_.appendix as appendix0_, barrierv1_.subComponentTypeID as subCompo4_0_, barrierv1_.componentStatusID as componen5_0_ from BarrierRoomLink barrierr0_, BarrierLookup barrierv1_ where barrierr0_.RoomID=? and barrierr0_.BarrierID=barrierv1_.BarrierID
2004-02-05 23:17:34,505 [Thread-4] DEBUG net.sf.hibernate.impl.BatcherImpl - preparing statement
2004-02-05 23:17:34,521 [Thread-4] DEBUG net.sf.hibernate.type.StringType - binding '109 ' to parameter: 1
2004-02-05 23:17:34,536 [Thread-4] DEBUG net.sf.hibernate.loader.Loader - result set contains (possibly empty) collection: [net.tripleTech.dao.RoomVO.barriers#109 ]
2004-02-05 23:17:34,536 [Thread-4] DEBUG net.sf.hibernate.impl.SessionImpl - uninitialized collection: initializing
2004-02-05 23:17:34,536 [Thread-4] DEBUG net.sf.hibernate.loader.Loader - processing result set
2004-02-05 23:17:34,536 [Thread-4] DEBUG net.sf.hibernate.loader.Loader - done processing result set ([b]0 rows[/b])
2004-02-05 23:17:34,536 [Thread-4] DEBUG net.sf.hibernate.impl.BatcherImpl - done closing: 0 open PreparedStatements, 0 open ResultSets
2004-02-05 23:17:34,552 [Thread-4] DEBUG net.sf.hibernate.impl.BatcherImpl - closing statement
2004-02-05 23:17:34,552 [Thread-4] DEBUG net.sf.hibernate.loader.Loader - total objects hydrated: 0
2004-02-05 23:17:34,552 [Thread-4] DEBUG net.sf.hibernate.impl.SessionImpl - 1 collections were found in result set
2004-02-05 23:17:34,552 [Thread-4] DEBUG net.sf.hibernate.impl.SessionImpl - collection fully initialized: [net.tripleTech.dao.RoomVO.barriers#109 ]
2004-02-05 23:17:34,552 [Thread-4] DEBUG net.sf.hibernate.impl.SessionImpl - 1 collections initialized





<class name="net.tripleTech.dao.RoleVO" table="RoleObject">
<id name="roleID">
<generator class="uuid.hex"/>
</id>
<property name="roleName"/>
<set name="rights" table="RoleRightLink" >
<key column="RoleID"/>
<many-to-many column="RightID" class="net.tripleTech.dao.RightVO"/>
</set>
</class>

<class name="net.tripleTech.dao.RightVO" table="RightObject">
<id name="rightID">
<generator class="uuid.hex"/>
</id>
<property name="rightName"/>
</class>


2004-02-05 22:52:07,502 [main] DEBUG net.sf.hibernate.impl.SessionImpl - initializing collection [net.tripleTech.dao.RoleVO.rights#20]
2004-02-05 22:52:07,502 [main] DEBUG net.sf.hibernate.impl.BatcherImpl - about to open: 0 open PreparedStatements, 0 open ResultSets
2004-02-05 22:52:07,502 [main] DEBUG net.sf.hibernate.impl.BatcherImpl - prepared statement get: select rolerigh0_.RightID as RightID__, rolerigh0_.RoleID as RoleID__, rightvo1_.rightID as rightID0_, rightvo1_.rightName as rightName0_ from RoleRightLink rolerigh0_, RightObject rightvo1_ where rolerigh0_.RoleID=? and rolerigh0_.RightID=rightvo1_.rightID
2004-02-05 22:52:07,502 [main] DEBUG net.sf.hibernate.impl.BatcherImpl - preparing statement
2004-02-05 22:52:07,518 [main] DEBUG net.sf.hibernate.type.StringType - binding '20' to parameter: 1
2004-02-05 22:52:07,518 [main] DEBUG net.sf.hibernate.loader.Loader - result set contains (possibly empty) collection: [net.tripleTech.dao.RoleVO.rights#20]
2004-02-05 22:52:07,534 [main] DEBUG net.sf.hibernate.impl.SessionImpl - uninitialized collection: initializing
2004-02-05 22:52:07,534 [main] DEBUG net.sf.hibernate.loader.Loader - processing result set
2004-02-05 22:52:07,534 [main] DEBUG net.sf.hibernate.type.StringType - returning '24' as column: rightID0_
2004-02-05 22:52:07,534 [main] DEBUG net.sf.hibernate.loader.Loader - result row: 24
2004-02-05 22:52:07,534 [main] DEBUG net.sf.hibernate.loader.Loader - Initializing object from ResultSet: 24
2004-02-05 22:52:07,534 [main] DEBUG net.sf.hibernate.loader.Loader - Hydrating entity: net.tripleTech.dao.RightVO#24
2004-02-05 22:52:07,534 [main] DEBUG net.sf.hibernate.type.StringType - returning 'AdministerUsers' as column: rightName0_
2004-02-05 22:52:07,534 [main] DEBUG net.sf.hibernate.type.StringType - returning '20' as column: RoleID__
2004-02-05 22:52:07,534 [main] DEBUG net.sf.hibernate.loader.Loader - found row of collection: [net.tripleTech.dao.RoleVO.rights#20]
2004-02-05 22:52:07,534 [main] DEBUG net.sf.hibernate.impl.SessionImpl - reading row
2004-02-05 22:52:07,534 [main] DEBUG net.sf.hibernate.type.StringType - returning '24' as column: RightID__
2004-02-05 22:52:07,549 [main] DEBUG net.sf.hibernate.impl.SessionImpl - loading [net.tripleTech.dao.RightVO#24]
2004-02-05 22:52:07,549 [main] DEBUG net.sf.hibernate.impl.SessionImpl - attempting to resolve [net.tripleTech.dao.RightVO#24]
2004-02-05 22:52:07,549 [main] DEBUG net.sf.hibernate.impl.SessionImpl - resolved object in session cache [net.tripleTech.dao.RightVO#24]
2004-02-05 22:52:07,549 [main] DEBUG net.sf.hibernate.loader.Loader - done processing result set (1 rows)
2004-02-05 22:52:07,549 [main] DEBUG net.sf.hibernate.impl.BatcherImpl - done closing: 0 open PreparedStatements, 0 open ResultSets
2004-02-05 22:52:07,549 [main] DEBUG net.sf.hibernate.impl.BatcherImpl - closing statement
2004-02-05 22:52:07,549 [main] DEBUG net.sf.hibernate.loader.Loader - total objects hydrated: 1


Top
 Profile  
 
 Post subject: Query with blanks
PostPosted: Fri Feb 06, 2004 1:32 am 
Newbie

Joined: Wed Dec 31, 2003 9:45 pm
Posts: 19
I discovered that the query Hibernate is generating is looking for room='109 ' (has several spaces after the actual number). In the database, there are no spaces, and in the returned RoomVO there are no spaces. This seems like I'm missing something pretty basic here, but I don't know where to look.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2004 1:34 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
show your code


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.