-->
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.  [ 3 posts ] 
Author Message
 Post subject: Transaction scoped identify and discriminator
PostPosted: Tue Mar 28, 2006 12:42 pm 
Newbie

Joined: Mon Nov 21, 2005 9:57 am
Posts: 4
I have a hierarchy: User <-- Applicant <-- Member. I use table-per-class-hierarchy to implement this hierarchy of classes in my mapping file, user.hbm.xml.
Code:
<class name="User" table="`user`" lazy="true" abstract="true" discriminator-value="U">
<discriminator column="type" type="java.lang.String" not-null="true" length="1" insert="false"/>
<property name="type" type="java.lang.Character" not-null="true"/>
...
<subclass name="Applicant" discriminator-value="A">
  <subclass name="Member" discriminator-value="M" >
  </subclass>
</subclass>
</class>

At some point in my application, I change the type of User from Applicant to Member by callling
Code:
setType("M")
, follow by some other initilization. This change and initialization are wrapped inside a transaction. My problem is that, after changing the discriminator value of Applicant, and flush it explicitly, I can't retrieve the object for type Member, which I want to use it to set member specific values. I know the fact that hibernate implements something called a transaction scope identify which causes this problem, but how do I fix this? I can solve it by changing the discriminator value in one transaction, and initialization in another, but I want them to be in one instead of two transactions.

Any advice is appreciated.


Top
 Profile  
 
 Post subject: evect?
PostPosted: Tue Mar 28, 2006 2:42 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
Did you try to evict the object from session and the attach it back?
session.evict( o );
and then
session.lock( o, ..);

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 29, 2006 9:03 pm 
Newbie

Joined: Mon Nov 21, 2005 9:57 am
Posts: 4
wopsss, that works! Thank you!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

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.