|
Hibernate version:
latest 3.1
Mapping documents:
important part
Well mapping:
<class name="com.volant.ppdm.module.well.model.WellHeader" table="WELL">
<id name="uwi" type="string">
<column name="UWI" length="20" />
<generator class="assigned" />
</id>
<property name="locationType" type="string">
<column name="LOCATION_TYPE" length="20" />
</property>
<any name="legalSurveyType" id-type="object" meta-type="string" insert="false" update="false" lazy="false">
<meta-value value="DLS" class="com.model.LegalDlsLoc"/>
<column name="legalSurveyType"/>
<column name="uwi"/>
<column name="locationType"/>
</any>
</class>
LegalDlsLoc mapping:
<class name="com.model.LegalDlsLoc" table="LEGAL_DLS_LOC">
<composite-id name="id" class="com.model.LegalDlsLocId">
<key-property name="legalDlsLoc" type="string">
<column name="LEGAL_DLS_LOC" length="20" />
</key-property>
<key-property name="locationType" type="string">
<column name="LOCATION_TYPE" length="20" />
</key-property>
</composite-id>
<many-to-one name="well" class="com.model.WellHeader" fetch="select">
<column name="UWI" length="20" />
</many-to-one>
</class>
Code between sessionFactory.openSession() and session.close():
NA
Full stack trace of any exception that occurs:
DEBUG [main] (Configuration.java:1046) - resolving reference to class: com.model.WellHeader
DEBUG [main] (Configuration.java:1046) - resolving reference to class: com.model.RLegalSurveyType
DEBUG [main] (Configuration.java:1046) - resolving reference to class: com.model.RLocationType
org.hibernate.MappingException: property mapping has wrong number of columns: com.model.WellHeader.legalSurveyType type: object
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:372)
at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
at org.hibernate.cfg.Configuration.validate(Configuration.java:921)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1085)
at com.SessionFactory.currentSession(SessionFactory.java:48)
at com.Test.testHibernateConfiguraiton(Test.java:30)
at com.Test.main(Test.java:25)
Exception in thread "main" java.lang.NullPointerException
at com.SessionFactory.currentSession(SessionFactory.java:55)
at com.Test.testHibernateConfiguraiton(Test.java:30)
at com.Test.main(Test.java:25)
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Question is about the <any> element
<any name="legalSurveyType" id-type="object" meta-type="string" insert="false" update="false" lazy="false">
<meta-value value="DLS" class="com.model.LegalDlsLoc"/>
<column name="legalSurveyType"/>
<column name="uwi"/>
<column name="locationType"/>
</any>
<column name="legalSurveyType"/>
should this be the name of the column for which I am keying off of? For instance legalSurveyType value "DLS" maps to table DLS_LOCATION
<column name="uwi"/> <column name="locationType"/>
do these columns have to map to the associated table id element?
What I am tryig to do is map a column in Well which contains a value representing the table name that needs to be queried to many tables whose ids are compsite-id.
That being said I do not want to use the composite-id of associated tables but 2 other columns.
example
table_A
table_name
column_one
column_five
table_C
column_three
column_seven
column_twenty
column_twenty-one
pk(column_three, column_seven)
table_D
column_three
column_seven
column_twenty
column_twenty-one
pk(column_three, column_seven)
table_E
column_three
column_seven
column_twenty
column_twenty-one
pk(column_three, column_seven)
so, table_A contains a column named tabl_name which contains the name of the table that row is associated with. table_name can contain values table "table_C", "table_D" and "table_E".
I want to use 2 columns (column_one, column_two) from table_A to dtermine which row to retrieve from C,D, or E. So,
table_A.column_one goes with table_(C,D,E).column_seven
table_A.column_five goes with table_(C,D,E).column_three
|