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: any type
PostPosted: Mon Jan 16, 2006 7:11 pm 
Newbie

Joined: Mon Jan 16, 2006 6:46 pm
Posts: 1
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


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.