-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: hbm2java - @Inheritance(strategy = InheritanceType.JOINED)
PostPosted: Wed Oct 21, 2009 9:07 am 
Newbie

Joined: Tue Oct 20, 2009 2:00 pm
Posts: 1
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


Top
 Profile  
 
 Post subject: Re: hbm2java - @Inheritance(strategy = InheritanceType.JOINED)
PostPosted: Wed Oct 28, 2009 6:25 am 
Senior
Senior

Joined: Tue Aug 04, 2009 7:45 am
Posts: 124
BTW. Your mapping file has errors because joined-subclass can't be enclosed into another joined-subclass.
Use the following meta attributes:
<meta attribute="extra-import">javax.persistence.Inheritance</meta>
<meta attribute="class-modifier">@Inheritance(strategy = InheritanceType.JOINED) public</meta>


Top
 Profile  
 
 Post subject: Re: hbm2java - @Inheritance(strategy = InheritanceType.JOINED)
PostPosted: Wed Oct 28, 2009 6:27 am 
Senior
Senior

Joined: Tue Aug 04, 2009 7:45 am
Posts: 124
>BTW. Your mapping file has errors because joined-subclass can't be enclosed into another joined-subclass.
I was mistaken, it just has '<' and '/>' lost characters.


Top
 Profile  
 
 Post subject: Re: hbm2java - @Inheritance(strategy = InheritanceType.JOINED)
PostPosted: Tue Nov 17, 2009 9:57 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
looks like bug in our generation.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: hbm2java - @Inheritance(strategy = InheritanceType.JOINED)
PostPosted: Mon Apr 30, 2012 4:39 pm 
Newbie

Joined: Fri Sep 16, 2005 10:04 am
Posts: 3
Sorry I tried to do the same today using hibernate-tools with ant; the jars are for hibernate-tools 3.40, copied from the eclipse indigo plugin (JBoss tools) from the directory names ...org.hibernate.eclipse.libs_3.4.0.v20120307-2104-H60-Beta1/xxxx

I still get no annotation @Inheritance, was there any progress on that ? Am I taking wrong version of the tool ?

Thanks in advance
Andrea


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.