Hi,
I would like to generate JPA from hbm files describing abstract classes. Everything is fine, except that hbm2java does not generate the annotation @Inheritance(strategy = InheritanceType.JOINED) when using joined-subclass: I have to add it manually and everything works. I tried using: <meta attribute="class-inheritance-type">single-table-per-class-hierarchy</meta> but that does not do a thing!
What meta attribute(s) will I need to set to generate @Inheritance(strategy = InheritanceType.JOINED)?
Here is my hbm file:
<hibernate-mapping package="gov.gsa.fas.offer.v1.persistence"> <class abstract="true" name="gov.gsa.fas.offer.v1.persistence.SolicitationGoodsAndServices" proxy="gov.gsa.fas.offer.v1.persistence.SolicitationGoodsAndServices" table="TB_GOODS_SERVICES"> <meta attribute="class-inheritance-type">single-table-per-class-hierarchy</meta> <id column="gsId" name="id" type="long"> <generator class="native"/> </id> <bag cascade="all-delete-orphan" inverse="true" lazy="true" name="childldrenSols"> <key column="pgsId"/> <one-to-many class="gov.gsa.fas.offer.v1.persistence.SolicitationGoodsAndServices"/> </bag> <many-to-one class="gov.gsa.fas.offer.v1.persistence.SolicitationGoodsAndServices" name="parentSol"> <column name="pgsId"/> </many-to-one> <joined-subclass extends="gov.gsa.fas.offer.v1.persistence.SolicitationGoodsAndServices" name="gov.gsa.fas.offer.v1.persistence.SolicitationGroup" table="TB_GROUP"> <key column="gsId"/> <property column="grp_name" generated="never" lazy="false" name="name" type="string"/> <property column="grp_order" generated="never" lazy="false" name="order" type="integer"/> </joined-subclass> <joined-subclass extends="gov.gsa.fas.offer.v1.persistence.SolicitationGoodsAndServices" name="gov.gsa.fas.offer.v1.persistence.SolicitationLineItem"> <key column="gsId"/> <joined-subclass extends="gov.gsa.fas.offer.v1.persistence.SolicitationLineItem" name="gov.gsa.fas.offer.v1.persistence.SIN" table="TB_SIN"> <key column="gsId"/> <property column="sin_number" generated="never" lazy="false" name="number" type="string"/> <property column="sin_title" generated="never" lazy="false" name="title" type="string"/> name="status" type="string"/> </joined-subclass> <joined-subclass extends="gov.gsa.fas.offer.v1.persistence.SolicitationLineItem" name="gov.gsa.fas.offer.v1.persistence.NSN" table="TB_NSN"> <key column="gsId"/> <property column="nsn_number" generated="never" lazy="false" name="number" type="string"/> <property column="nsn_group" generated="never" lazy="false" name="group" type="string"/> <property column="nsn_title" generated="never" lazy="false" name="title" type="string"/> <property column="nsn_description" generated="never" lazy="false" </joined-subclass> </joined-subclass> </class> </hibernate-mapping>
This code generate exactly what I want minus the @Inheritance (commented)
@Entity @Table(name="TB_GOODS_SERVICES") //@Inheritance(strategy = InheritanceType.JOINED) - this should also be generated by hbm2java public class CopyOfSolicitationGoodsAndServices implements java.io.Serializable { private long id; private Collection<CopyOfSolicitationGoodsAndServices> childldrenSols = new ArrayList<CopyOfSolicitationGoodsAndServices>(0); private CopyOfSolicitationGoodsAndServices parentSol; ....
@Entity @Table(name="SolicitationLineItem") //@Inheritance(strategy=InheritanceType.JOINED) - this should also be generated by hbm2java public class CopyOfSolicitationLineItem extends gov.gsa.fas.offer.v1.persistence.SolicitationGoodsAndServices implements java.io.Serializable { public CopyOfSolicitationLineItem() { }
public CopyOfSolicitationLineItem(Collection<SolicitationGoodsAndServices> childldrenSols, SolicitationGoodsAndServices parentSol) { super(childldrenSols, parentSol); }
Cheers, JP
|