Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.1
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!--
Auto-generated mapping file from
the hibernate.org cfg2hbm engine
-->
<class name="com.volant.wellcatalog.model.VsiWell" table="vsi_well" catalog="wellcatalog" lazy="false">
<composite-id name="id" class="com.volant.wellcatalog.model.VsiWellId">
<key-property name="uwi" type="string">
<column name="UWI" length="20" />
</key-property>
<key-property name="source" type="string">
<column name="SOURCE" length="60" />
</key-property>
</composite-id>
<property name="country" type="string">
<column name="COUNTRY" length="20" />
</property>
<property name="provinceState" type="string">
<column name="PROVINCE_STATE" length="20" />
</property>
<property name="county" type="string">
<column name="COUNTY" length="20" />
</property>
<property name="latitude" type="double">
<column name="LATITUDE" precision="13" scale="9" />
</property>
<property name="longitude" type="double">
<column name="LONGITUDE" precision="13" scale="9" />
</property>
<property name="bhLatitude" type="double">
<column name="BH_LATITUDE" precision="13" scale="9" />
</property>
<property name="bhLongitude" type="double">
<column name="BH_LONGITUDE" precision="13" scale="9" />
</property>
<property name="township" type="float">
<column name="TOWNSHIP" precision="6" scale="1" />
</property>
<property name="range" type="float">
<column name="RANGE" precision="5" scale="1" />
</property>
<property name="section" type="float">
<column name="SECTION" precision="5" scale="1" />
</property>
<property name="nsDirection" type="string">
<column name="NS_DIRECTION" length="20" />
</property>
<property name="ewDirection" type="string">
<column name="EW_DIRECTION" length="20" />
</property>
<property name="operator" type="string">
<column name="OPERATOR" length="60" />
</property>
<property name="totalDepth" type="float">
<column name="TOTAL_DEPTH" precision="10" scale="5" />
</property>
<property name="leaseName" type="string">
<column name="LEASE_NAME" length="60" />
</property>
<property name="currentStatus" type="string">
<column name="CURRENT_STATUS" length="60" />
</property>
<property name="currentClass" type="string">
<column name="CURRENT_CLASS" length="60" />
</property>
<property name="abstractt" type="string">
<column name="ABSTRACT" length="20" />
</property>
<property name="survey" type="string">
<column name="SURVEY" length="60" />
</property>
<property name="ocsBlock" type="string">
<column name="OCS_BLOCK" length="6" />
</property>
<property name="ocsArea" type="string">
<column name="OCS_AREA" length="20" />
</property>
<property name="spudDate" type="date">
<column name="SPUD_DATE" length="10" />
</property>
<property name="completionDate" type="date">
<column name="COMPLETION_DATE" length="10" />
</property>
<property name="isActive" type="string">
<column name="IS_ACTIVE" length="60" />
</property>
<set name="vsiWellLogs" inverse="true" lazy="false">
<key>
<column name="UWI" length="20" not-null="true" />
<column name="SOURCE" length="60" not-null="true" />
</key>
<one-to-many class="com.volant.wellcatalog.model.VsiWellLog"/>
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
String hql = buildQuery("SELECT new com.volant.wellcatalog.model.WellLogs(w.id.uwi,logs) " +
"\nFROM VsiWell as w \n left join w.vsiWellLogs as logs");
Full stack trace of any exception that occurs:NA
Name and version of the database you are using:MySQL
The generated SQL (show_sql=true):See above
Debug level Hibernate log excerpt:NA
I am trying to accomplish the same result that is shown in the Cats example in the documentation when using a type safe object in the select clause. I have one record in the VsiWell table and 2 records in the VsiWellLog table. For some reasonHibernate is returning 2 entries in the resulting list. I expect it to return 1, with two VsiWellLog objects in the WellLogs object.
I assume the Family in the Cats example should have declared a contructor as follows Family(DomesticCat a, DomesticCat mate, Ktittens kittens). When I declared WellLogs as (String uwi, Set<VsiWellLogs> logs) hibernate told me that it could not find the appropriate constructor, so switched to (Stiring uwi, VsiWellLog log) and the query worked, but returned unepected results as mentioned above.
Any help would be appreciated.
[/code]