-->
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: Mapping: Default value
PostPosted: Fri Nov 17, 2006 3:34 pm 
Newbie

Joined: Wed Sep 06, 2006 8:33 am
Posts: 19
I can map two class in a same table?

The class:

ClassA
ID
Property1

ClassB
ID
Property1

The table:
TBL
ID
ClassName
Property1

I create 2 mapping files, to ClassA and ClassB. But, the table have "ClassName" i can specify the ClassName in the mapping file to default value?

Sorry, my english is poor.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 17, 2006 4:14 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
If I followed you correctly, you want to map one table in more than one objects ? Isn't it ?

If so, yes. It's possible.

If you want that one line of one would create objects of one class A or class B, then it is also possible. I guess it would be to do some kind of inheritance ? Maybe you could give a bit more realistic example so as to help us to help you :-).

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 20, 2006 10:26 am 
Senior
Senior

Joined: Sat Mar 25, 2006 9:16 am
Posts: 150
Yes, you need to use subclass tag with discriminator values. You need to make your Class A and B derive from the same base class.

http://www.hibernate.org/hib_docs/nhibe ... n-subclass


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.