Hibernate version:2.1.6 on jdk 1.4.2_05
I am very much a newbie and am working with a complex set of mappings that I generated with Middelgen and hbm2java. After generating all the xml mappings and .java files (which compile ok). I attempt to build a sesssionFactory and get an exception in:
buildSessionFactory()
Configuration c = new Configuration();
File file = new File("C:/_di/hibernatetest/src/com/drillinginfo/pennwell/hibernate/mapping");
c.addDirectory(file);
sessionFactory = c.buildSessionFactory(); //throws exception
Full stack trace of any exception that occurs:
Caused by: net.sf.hibernate.MappingException: identifier mapping has wrong number of columns: com.drillinginfo.pennwell.hibernate.WellboreTubingNarrative type: com.drillinginfo.pennwell.hibernate.WellboreTubingNarrativePK
at net.sf.hibernate.mapping.RootClass.validate(RootClass.java:171)
at net.sf.hibernate.cfg.Configuration.validate(Configuration.java:619)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:785)
I know that if I cut out the <key-many-to-one> in the composite-id, I do not have an error.
I tried stepping thru the hibernate code and it appears for whatever reason, the RootClass, in this case a WellboreTubingNarrative, is loaded with a Identifier (a WellboreTubingNarrativePK) that has 0 columns. Since the mapping for the WellboreTubingNarrativePK has 4 columns, the Component.isValid(Mapping) throws the exception. I cant figure out why the RootClass is not properly initialized.
Mapping documents:/b]
-------------------------------------------------------------------------
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin
http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class
name="com.drillinginfo.pennwell.hibernate.WellboreTubingNarrative"
table="WELLBORE_TUBING_NARRATIVE"
>
<composite-id name="comp_id" class="com.drillinginfo.pennwell.hibernate.WellboreTubingNarrativePK">
<key-property
name="dataSourceCode"
column="DATA_SOURCE_CODE"
type="java.lang.String"
length="32"
/>
<key-property
name="sequenceNumber"
column="SEQUENCE_NUMBER"
type="java.lang.Integer"
length="10"
/>
<key-property
name="subSequenceNumber"
column="SUB_SEQUENCE_NUMBER"
type="java.lang.Integer"
length="10"
/>
<!-- bi-directional many-to-one association to Wellbore -->
<key-many-to-one
name="wellbore"
class="com.drillinginfo.pennwell.hibernate.Wellbore"
>
<column name="SYSTEM_WELL_ID_NUMBER" />
<column name="WELL_COMPLETION_NUMBER" />
</key-many-to-one>
</composite-id>
<property
name="uwiDataSource"
type="java.lang.String"
column="UWI_DATA_SOURCE"
length="20"
/>
<property
name="narrative"
type="java.lang.String"
column="NARRATIVE"
length="128"
/>
<property
name="recordLoadDate"
type="java.sql.Timestamp"
column="RECORD_LOAD_DATE"
length="23"
/>
<property
name="recordModificationDate"
type="java.sql.Timestamp"
column="RECORD_MODIFICATION_DATE"
length="23"
/>
<property
name="recordModificationBy"
type="java.lang.String"
column="RECORD_MODIFICATION_BY"
length="32"
/>
<!-- associations -->
</class>
</hibernate-mapping>
-------------------------------------------------------------------------
[b]Name and version of the database you are using:ms sql2k
Debug level Hibernate log excerpt: