-->
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.  [ 2 posts ] 
Author Message
 Post subject: update and discriminator issue (mutable class issue)
PostPosted: Fri Dec 21, 2007 5:26 am 
Newbie

Joined: Thu Oct 06, 2005 5:36 am
Posts: 8
Hibernate is not updating 'DiscriminatorColumn' on 'InheritanceType.SINGLE_TABLE' inheritance.

In the case you change the type of the class (mutate the object class -> recreate a new class). The discriminator column in not updated.

Is there a workaround using the annotations.

We found one workaround changing the persister update statement :

final SingleTableEntityPersister persister = (SingleTableEntityPersister) sess.getEntityPersister(null, anObjectOfClassA );
//
// Use reflection to access that method..
final Method getSQLUpdateStrings = AbstractEntityPersister.class.getDeclaredMethod("getSQLUpdateStrings");
getSQLUpdateStrings.setAccessible(true);
//
// Add the discriminator at the beginning of the request.
final String[] updates = (String[]) getSQLUpdateStrings.invoke(persister);
updates[0] = updates[0].replace("update CLASS_A_TABLE set", "update CLASS_A_TABLE set CLASS_A_TABLE_KIND='TERM', ");


Top
 Profile  
 
 Post subject: Re: update and discriminator issue (mutable class issue)
PostPosted: Sat Dec 22, 2007 5:29 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
DavidAlvarez wrote:
In the case you change the type of the class (mutate the object class -> recreate a new class). The discriminator column in not updated.

Is there a workaround using the annotations.


You will have to explain me how you mutate a class from one type to another in Java or any OO language, it's just magic :)

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.