-->
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: modify type value in "table per subclass"
PostPosted: Mon Jun 04, 2007 2:38 am 
Newbie

Joined: Tue Apr 03, 2007 5:42 am
Posts: 13
i want to know the method that modify type value in "table per subclass".

example,

Member class (Parent class)
- tablename : MEMBERS
- type value: "group" (discriminator value)

User Class (Chidren class)
- tablename : MEMBER_USER
- type value : "user" (discriminator value)
- name : "Smith"

Department Class (Childrent Class)
- tablename : MEMBER_DEPARTMENT
- type value: department (discriminator value)
- code : "dep01"

i want to changed type and class (user class -> departemnt class)

next, sample code. but it's incorrect code.

Code:
Member member= (User)session.load(Member.class, memberSeq);
member = new Department();
(Department)member.setCode("dep01");
session.update(member);


but, our database's type value never changed. how can i solve this problem?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 04, 2007 11:03 am 
Beginner
Beginner

Joined: Thu Nov 02, 2006 9:38 am
Posts: 32
Location: Belgium
I'm pretty sure that's impossible. What you actually want to do, is change the type of an object, which is impossible in Java. Since Hibernate maps to Java objects, it makes sense that Hibernate disallows it as well.

Consider that you already have a reference to the object, then magically change the type of said object through hibernate... what would happen to your previously fetched (and hence cached) object?

If you really need to do this, you'd have to do the SQL work manually outside of a Hibernate session. But it's more likely that something in your design is flawed - though I could easily be wrong.


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.