-->
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: descrimniator problem
PostPosted: Wed Apr 12, 2006 9:04 pm 
Newbie

Joined: Wed Apr 12, 2006 8:53 pm
Posts: 2
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

3.1.3

Mapping documents:
<hibernate-mapping package="edu.msu.egr.decs.alumni.database.dataobjects">

<class name="profile" table="profile">
<cache usage="read-write"/>
<id name="ID" column="profile_id" type="java.lang.Integer">
<generator class="sequence">
<param name="sequence">profile_id_seq</param>
</generator>
</id>

<property name="departmentJobAreaID" update="false" insert="false" column="department_job_area_id" type="java.lang.Integer" not-null="false" />

<set name="personalEmails" batch-size="2" cascade="all" inverse="true">
<key column="profile_id"/>
<one-to-many class="edu.msu.egr.decs.alumni.database.dataobjects.PersonalEmail"/>
</set>
<set name="workEmails" batch-size="2" cascade="all" inverse="true">
<key column="profile_id"/>
<one-to-many class="edu.msu.egr.decs.alumni.database.dataobjects.WorkEmail"/>
</set>


</class>
</hibernate-mapping>

<hibernate-mapping package="edu.msu.egr.decs.alumni.database.dataobjects">

<class name="Email" table="email">
<id name="ID" column="email_id" type="java.lang.Integer">
<generator class="sequence">
<param name="sequence">email_id_seq</param>
</generator>
</id>

<discriminator column="maintnence_email_type_id" type="string"/>



<property name="email" column="email" type="java.lang.String" not-null="true" />
<property name="profileID" insert="false" update="false" column="alumni_profile_id" type="java.lang.Integer" />

<many-to-one name="profile" column="alumni_profile_id" class="edu.msu.egr.decs.alumni.database.dataobjects.AlumniProfile" not-null="true"/>

<subclass
name="edu.msu.egr.decs.alumni.database.dataobjects.PersonalEmail"
discriminator-value="2" />
<subclass
name="edu.msu.egr.decs.alumni.database.dataobjects.WorkEmail"
discriminator-value="1" />



</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
Caused by lazy initiatization. basicly

mySession.reconnect()
Set mySet = myProfile.getWorkEmails()
mySession.disconnect


mySet will have records that are PersonalEmail

Full stack trace of any exception that occurs:
I end up with Class Cast Exceptions because You can't cast PersonalEmail to WorkEmail.

Name and version of the database you are using:
Postgres 7.4

The generated SQL (show_sql=true):

20:45:21,281 INFO [STDOUT] Hibernate: select personalem0_.alumni_profile_id as alumni10_1_, personalem0_.email_id as email1_1_, personalem0_.email_id as email1_10_0_, personalem0_.stakeholder_created_by_id as stakehol3_10_0_, personalem0_.stakeholder_changed_by_id as stakehol4_10_0_, personalem0_.last_modified as last5_10_0_, personalem0_.start_date as start6_10_0_, personalem0_.end_date as end7_10_0_, personalem0_.created_date as created8_10_0_, personalem0_.email as email10_0_, personalem0_.alumni_profile_id as alumni10_10_0_, personalem0_.maintnence_email_type_id as maintnence2_10_0_ from email personalem0_ where personalem0_.alumni_profile_id=?
20:45:37,906 INFO [STDOUT] Hibernate: select workemails0_.alumni_profile_id as alumni10_1_, workemails0_.email_id as email1_1_, workemails0_.email_id as email1_10_0_, workemails0_.stakeholder_created_by_id as stakehol3_10_0_, workemails0_.stakeholder_changed_by_id as stakehol4_10_0_, workemails0_.last_modified as last5_10_0_, workemails0_.start_date as start6_10_0_, workemails0_.end_date as end7_10_0_, workemails0_.created_date as created8_10_0_, workemails0_.email as email10_0_, workemails0_.alumni_profile_id as alumni10_10_0_ from email workemails0_ where workemails0_.alumni_profile_id=?

Hibernate isn't putting the discriminator value in. thanks.


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.