-->
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.  [ 8 posts ] 
Author Message
 Post subject: Xdoclet and subclasses mapping
PostPosted: Fri Feb 06, 2004 8:43 am 
Beginner
Beginner

Joined: Fri Feb 06, 2004 6:59 am
Posts: 36
Location: S
I understood the way it is tended to do the subclass mapping but it does not attend what I need to have.

I have several tables in my model with the same design.
tableA
tableB


I have one class that describes all the fields of this tables.
MasterClass

I have several other classes that inherits this one class.
MinorClass1
MinorClass2

...

I whould like to put in the class MinorClass1 a mapping to the tableA
and for the MinorClass2 a mapping to the tableB without having to map it individually and make use of inheritance on both classes to the superclass MasterClass that this one has the atributes and getters and setters.

Is there a way to do this?

_________________
Best Regards,
Ernani Joppert Pontes Martins


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2004 10:48 pm 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
Look at the subclass element in the mapping schema. This does what I think you are trying to do.

Sherman


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 07, 2004 4:00 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Your only real option for mapping something like this is table-per-concrete-class IMHO. (you have no table for MasterClass, so no joined-subclass). I don't know if you can get XDoclet to search the superclass for properties though, I think there is some way, just try it.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 07, 2004 11:34 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I think I've done that before. Xdolcet will look at your parent hierarchy to find mapped properties. So just add your @hibernate.property in your parent class.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Though to do it
PostPosted: Mon Feb 09, 2004 5:31 am 
Beginner
Beginner

Joined: Fri Feb 06, 2004 6:59 am
Posts: 36
Location: S
The only problem I have if I do table-per-concrete class mapping is then I will have to set the @hibernate.id for all of them and map the table on each class and in the superclass I will have also to map it to a table, could be a dummy table but this IMHO is a really nasty model.

Any clues folks?

_________________
Best Regards,
Ernani Joppert Pontes Martins


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 09, 2004 6:26 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
No, with table-per-concrete-class you don't map your superclass at all. Take a look at http://www.hibernate.org/hib_docs/reference/html/inheritance.html#inheritance-s1


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 09, 2004 6:53 am 
Beginner
Beginner

Joined: Fri Feb 06, 2004 6:59 am
Posts: 36
Location: S
Nice, seems to be that it whould work then but not at all because I will have to map the id of the subclasses into the subclasses and the superclass is the one with the id, I will use all fields of the superclass and no one on the subclasses...

Thanks for all

_________________
Best Regards,
Ernani Joppert Pontes Martins


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 09, 2004 6:57 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
It doesn't matter where your properties are defined. Just map them in the subclass, the subclass can be empty as long as the properties are defined in the superclass.


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