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 BUG?!
PostPosted: Thu Mar 06, 2008 6:22 pm 
Newbie

Joined: Thu Mar 06, 2008 6:18 pm
Posts: 2
Hibernate version: 3.2.5

I am trying to map two classes to the same table and it works fine. Is this not a problem? Shouldn't I be getting some kind of a Duplicate Mapping Exception?

Thanks,
Bijal


Top
 Profile  
 
 Post subject: Re: Hibernate BUG?!
PostPosted: Thu Mar 06, 2008 6:25 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
bijaleez wrote:
Hibernate version: 3.2.5

I am trying to map two classes to the same table and it works fine. Is this not a problem? Shouldn't I be getting some kind of a Duplicate Mapping Exception?

Thanks,
Bijal



It's fine.



Farzad-


Top
 Profile  
 
 Post subject: response to Farzad
PostPosted: Thu Mar 06, 2008 6:35 pm 
Newbie

Joined: Thu Mar 06, 2008 6:18 pm
Posts: 2
Well the reason why I question this is because when I tried to do this with a subclass it does throw a Duplicate Mapping Exception. Let me explain a bit further:

Scenario A:
<class name="ClassA" table="table_a">
...
</class>

<class name="ClassB" table="table_a">
...
</class>


Scenario B:
<class name="ClassA" table="table_a">
...
</class>

<class name="ClassB" abstract="true">
<union-subclass name="ClassC" table="table_a">
...
</union-subclass>
</class>

Scenario 2 throws a Dupplicate Mapping Exception, but Scenario A works fine. Whats the difference? Why doesn't Scenario B work?

Thanks,
Bijal


Top
 Profile  
 
 Post subject: Re: response to Farzad
PostPosted: Thu Mar 06, 2008 6:40 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
the semantics are different here. Read hibernate documentation for an explanation of union subclass. In case of regular mapping imagine this scenario: There is ClassA and There is ClassAForListing which has less fields and probably no association and is good for a specific screen that shows a list of instances. Then it perfectly makes sense to need to maps a table more than once but one need to be more cautious not violate any data integrity of any kind because hibernate in these cases can guarantee less things.



Farzad-


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.