I would like to use the tool to generate classes from mapping files and make this part of my build process. So if, for example, I add a new property to a class it will automatically become part of my compiled code. But in order to add methods to my generated classes I think I need to extend the persisted classes and add methods to the derived class. That way the generated class is not touched and can be replaced by the automated process.
Here is a class generated from a mapping file that will be persisted:
class Persisted
{
....
}
Here is my derived class which adds new methods, but no new properties:
class Derived extends Persisted
{
public void MyCustomMethod()
{
....
}
}
The question is, can I create objects of type Derived and have the Hibernate runtime persist it even though the mapping file has been written for the Persisted class? I can fake this by changing name of the class in the mapping file to the Derived class but I'm assuming there must be a proper way of doing it.
Thanks!
|