I have a simple interface with id, version and name. A single class implements this interface.
I want to create a mapping file that is based on the interface and results in Hibernate persisting the implementation class. The mapping files I have created so far use joined-subclass. They result in multiple insert statements and missing fields that violate non-null integrity constraints.
Listed below are the interface and my current attempt at a mapping file.
Any suggestions on the mapping file would be greatly appreciated.
Code:
public interface Foo {
public Long getId();
public void setId(Long id);
public Integer getVersion();
public void setVersion(Integer version);
public String getName();
public void setName(String name);
}
Code:
<hibernate-mapping>
<class abstract="true" name="com.sample.model.Foo" table="FOO">
<id name="id" type="java.lang.Long">
<column name="ID" />
<generator class="native" />
</id>
<version column="VERSION" generated="never" insert="false"
name="version" type="integer" />
<property generated="never" lazy="false" name="name"
type="java.lang.String">
<column name="NAME" />
</property>
<joined-subclass name="com.sample.model.internal.FooImpl">
<key column="id" />
</joined-subclass>
</class>
</hibernate-mapping>