I've this class-structure with a parentobject that has the basics every hibernated object should have in my application (ID, version, etc). Now I don't want to store this objecttype, since it is never actually used, only its subclasses.
But I can't figure out how to nicely store the properties of this object in a non-general way, I'd rather not name all id-fields in my database 'ID'. So I have something like this:
Code:
class Identifier
{
Long id;
Date lastEditDate;
public getId(){return id}
public setId(Long newId){id = newId}
...
}
class RealObject extends Identifier
{
String someProp;
...
}
<hibernate-mapping>
<class name="SomeObject" table="SomeObjects">
<id name="id" column="someObjectID">
<generator class="identity"/>
</id>
<timestamp name="lastEditDate" />
<property name="someProp" />
</class>
</hibernate-mapping>
So what I want is to keep using this class-structure and run with Annotations. But I don't want that Identifier-class to be stored in the database (is it an Entity than or not?), I especially don't want a root-table for this objecttype where all objects have their identity-stuff stored... That doesn't strike me as very performant or nice database-usage.
But I do want to use the object's id/lastEditDate, without specifying another getId/getLastEditDate-set of methods for each class.
Is that possible, if so how? If not, should it be/what is a good alternative?