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.  [ 1 post ] 
Author Message
 Post subject: Hibernate Inheritance with Libraries
PostPosted: Thu Jan 07, 2010 2:10 pm 
Newbie

Joined: Mon Jun 18, 2007 2:08 pm
Posts: 10
Hibernate Version: 3.2.2ga
Language: Java

I would like to know if the following is possible, and - if so - how.

We have a library that has classes mapped through annotation.

I would like to know if it is possible to extend a class in the library being used and override the annotations or extends the annotation.

Example:

(1)

In the library:

@Entity
@Table(name = "CAR")
class Car
{
... mappings and methods for all the ids and some fields
}


Now I would like to etends the class Car in the project that uses the library so that I can add additional mapping (i.e. assume that the table for the project has more columns that what is mapped on the lib)

@Entity
@Table(name = "CAR")
Class ExtendedCar extends Car
{
// add mapping only for the columns that are "extra" on the table.
}


2) Is that possible to also override the return type and how to tell hibernate to load the correct class.

class Car
{
// removed annotations for brevity
Owner getOwner()
}

// Outside the library

class ExtendedCar extends Car
{
Owner getOwner()
{
// actually returns a ExtendedOwner
}
}

class ExtendedOwner extends Owner
{
.. mapping.
}



I have seen docs that describes this (http://docs.jboss.org/hibernate/stable/ ... gle/#d0e41) but it actually requires (1) either a complete set of mappings or the entire mapping is in XML files - that is not possible
becuase the library cannot be modified.

I also have seen requests for hibernate to implements such a thing, which clues me that it is not supported. Am I correct?

Thank you in advance.

Harring.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.