-->
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: Can I persist a mutable class
PostPosted: Mon Nov 07, 2005 8:10 am 
Newbie

Joined: Thu Jul 07, 2005 6:59 am
Posts: 13
Location: Derry Northern Ireland
Hi can I persist a class that effectively like this,

I have a concrete class called GlobalRule,
which I want to change to an interface,

I have concrete classes that will then implement GlobalRule,
RuleA,
RuleB,
RuleC etc,

in our framework design we want to change GlobalRule which is currently a concrete class to an interface so that we create many types of rule objects and then persist,

is there a way in hibernate so I can then persist GlobalRule without getting the error cannot instantiate an abstract class or interface error that hibernate throws.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 07, 2005 9:24 am 
Beginner
Beginner

Joined: Tue Jun 07, 2005 11:36 pm
Posts: 22
There are, in fact, many different ways to do that. This is a good thing if you like choice and a bad thing if you don't like your head exploding the first time you try to decide which way to do it. Read Chap 10 of the manual for the details. I recommend setting up a tiny testing project with classes like "BaseClass" and "JoinedSubClass" and "DiscriminatorSubClass" and test out each section of Chap 10 before trying to read the whole thing. It will keep spontaneous noggin combustion to a minimum.

For what it's worth, if your GlobalRule classes are all very similar, you probably want the approach in section 10.1.1. Table per class hierarchy. If they have a lot of different fields, then 10.1.2. Table per subclass is good. Those are the two main ones, and unless you have a pretty complex mix-in class hierarchy that you want to persist, one or the other should work for you.

-----
Eric

Helpful? Hit me with a credit!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 07, 2005 3:16 pm 
Newbie

Joined: Thu Jul 07, 2005 6:59 am
Posts: 13
Location: Derry Northern Ireland
Thanks a million I'll look into this?


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.