-->
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.  [ 1 post ] 
Author Message
 Post subject: HQL not returning single row
PostPosted: Mon Mar 09, 2009 11:32 am 
Newbie

Joined: Mon Mar 09, 2009 11:17 am
Posts: 2
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 2.1.8

Mapping documents:
Code:
<hibernate-mapping package="com.xxx.vendor.event" default-access="field">
   <class name="VendorEvent" table="VENDOR_EVENT" lazy="true">
      <id name="primaryKey" type="integer" column="VENDOR_EVENT_SQ">
         <generator class="assigned"/>
      </id>
      
      <many-to-one name="vendor" column="VENDOR_SQ" not-null="true" />
      <many-to-one name="eventCode" column="EVENT_CD" not-null="true"/>
      <property name="createDate" column="CREATE_DT" not-null="true"/>
      <property name="createUserId" column="CREATE_USER_ID" not-null="true"/>
      <property name="comments" column="COMMENTS_TX"/>
      <many-to-one name="participatingVendor" column="PARTICIPATING_VENDOR_SQ" />
      
   </class>
</hibernate-mapping>


Code:
<hibernate-mapping package="com.xxx.vendor" default-access="field">
   <class name="Vendor" table="VENDOR" lazy="true">
      <id name="primaryKey" type="integer" column="VENDOR_SQ">
         <generator class="assigned"/>
      </id>
      
      <version name="version" column="VERSION_NO" unsaved-value="negative" />
         .
         .
         .      
      
      <set name="eventsHistory" lazy="true" cascade="all-delete-orphan" inverse="true" sort="natural">
         <key column="VENDOR_SQ"/>
         <one-to-many class="com.xxx.vendor.event.VendorEvent"/>
      </set>
      
   </class>
</hibernate-mapping>


Name and version of the database you are using:Oracle 11g

Can anyone tell me why this HQL doesn't return a single row? I read the item in the faq but it doesn't seem to apply as their are no outer-joins here. Putting in DISTINCT gives me what I want, but I don't understand why I need the DISTINCT in the first place.

When I do a showsql, the VENDOR_EVENT table is added twice to the FROM clause.

select e.participatingVendor from VendorEvent e where e.vendor.id = :id and e.eventCode.id = 'BUYOUT'[/code]


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

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.