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]