We have some requirements for our project that will require us to access all persistent data via interfaces. In order to save time I'd like to drive both the generation of Hibernate mapping (xml) files and the actual Java classes that implement the persistent interfaces from XDoclet tags on the persistent interface. Here is an example:
Say I have a simple persistent interface:
Code:
package eg;
public interface Test
{
public long getId();
public void setId(long id);
public String getName();
public void setName(String name);
}
Since nothing special will be required of the XML or the Java, I'd love to just write the interface and be done with it. Let XDoclet generate the xml and Java code for me. Has anyone done anything like this?
I envision something like this:
Code:
package eg;
/**
* @hibernate.class table="test"
* @hibernate.generate-subclass name="eg.TestImpl"
*/
public interface Test
{
/**
* @hibernate.id unsaved-value="0" generator-class="native"
*/
public long getId();
public void setId(long id);
/**
* @hibernate.property
*/
public String getName();
public void setName(String name);
}
Notice how I put a @hibernate.generate-subclass tag in there along with the @hibernate.class.
Anyway, if, in the end all my .xml and generic .java Impl classes were autogenerated, I would be a happy camper. Has anyone done this, or does this even make sense?
- Anodos