-->
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: inheritance: table per concrete class using polymorphism
PostPosted: Wed Aug 31, 2005 8:10 am 
Newbie

Joined: Mon Jul 11, 2005 12:25 pm
Posts: 7
Location: Dublin, Ireland
I am trying to map an inheritance relationship using table per concrete class, using implicit polymorphism. I have been trying to follow the example in the documentation but it is very unclear. I have two concrete classes: car and bicycle that need to implement the interface vehicle. The interface vehicle has the common properties: id, and color. My mappings look like this:

<class name="Car" table="tbl_car">
<id name="id" column="pk_car_id" type="integer">
<generator class="native"/>
</id>
<property name="color" column="car_color" type="string"/>
<property name="licenseNumber" column="license_number" type="string"/>

<any name="vehicle" meta-type="string" id-type="integer">
<meta-value value="CAR" class="Car"/>
<meta-value value="BIKE" class="Bicycle"/>
<column name="color"/>
<column name="id"/>
</any>
</class>

<class name="Bicycle" table="tbl_bicycle">
<id name="id" column="pk_bicycle_id" type="integer">
<generator class="native"/>
</id>
<property name="color" column="bicycle_color" type="string"/>
<property name="isMountainBike" column="is_mountain" type="boolean"/>

<any name="vehicle" meta-type="string" id-type="integer">
<meta-value value="tbl_car" class="Car"/>
<meta-value value="tbl_bicycle" class="Bicycle"/>
<column name="color"/>
<column name="id"/>
</any>
</class>

I know that this isn't right but I am trying to figure out how to correctly use the any attribute to achieve this mapping. I can't figure it out from the documentation.


Top
 Profile  
 
 Post subject: Re: inheritance: table per concrete class using polymorphism
PostPosted: Wed Aug 31, 2005 8:54 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
I don't think what you're describing requires the <any> mapping or is the correct use for it.

Just because your Java objects use inheritance, doesn't mean your mapping requires it. It looks to me like your example would work fine if you just removed the <any> mappings.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 31, 2005 9:11 am 
Newbie

Joined: Mon Jul 11, 2005 12:25 pm
Posts: 7
Location: Dublin, Ireland
If that's the case then what is that whole section 9.1.6 in the hibernate manual entitled "Table per concrete class, using implicit polymorphism" talking about:

http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#inheritance-tableperconcreate-polymorphism

It clearly seems to state that you should use the any tag for this sort of relationship. I am just trying to figure out exactly what it is trying to say.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 31, 2005 9:29 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
snake068 wrote:
If that's the case then what is that whole section 9.1.6 in the hibernate manual entitled "Table per concrete class, using implicit polymorphism" talking about:

http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#inheritance-tableperconcreate-polymorphism

It clearly seems to state that you should use the any tag for this sort of relationship. I am just trying to figure out exactly what it is trying to say.


I believe this is talking about another object that might have any one of these objects as a property.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


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.