-->
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.  [ 4 posts ] 
Author Message
 Post subject: Hibernate 3.x Implicit Mapping?
PostPosted: Wed Sep 28, 2005 2:00 am 
Regular
Regular

Joined: Thu Feb 17, 2005 1:58 am
Posts: 63
Regarding Hibernate 3.x

Here is my hibernate mapping:

...
<class
name="hibernate.Employee"
table="Employee"
>
...

public class RealEmployee extends hibernate.Employee


Can I persist RealEmployee without specifying an explicit mapping?

Thanks,


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 28, 2005 5:43 am 
Newbie

Joined: Tue May 17, 2005 10:55 am
Posts: 7
I would say no.

Don't forget that databases model 'has-a' relationships, not 'is-a', so the database wont understand that RealEmployee extends Employee.

Without the mapping file how would Hibernate know which properties of RealEmployee to persist?

Chapter 3.6 of Hibernate in action gives a very good overview of inheritance. Also chapter 10 of the docs should help.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 28, 2005 6:38 am 
Newbie

Joined: Tue May 17, 2005 10:55 am
Posts: 7
I've just tried this, and you can persist a RealEmployee using only an Employee mapping file.

But obviously only the properties inherited from Employee are persisted.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 28, 2005 10:37 am 
Regular
Regular

Joined: Thu Feb 17, 2005 1:58 am
Posts: 63
sdm wrote:
I've just tried this, and you can persist a RealEmployee using only an Employee mapping file.

But obviously only the properties inherited from Employee are persisted.


I was about to tried myself. Thanks for trying. You saved me the time :)

Yeah, RealEmployee data members are all transient, so I won't need to persist them.

It makes sense it should work. I have not yet looked at Hibernate code but it must traversing the inheritance hierarchy and map the class at each level, if one was available.


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