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.