Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Teneo passes annotations?
Teneo passes annotations? [message #424668] Fri, 31 October 2008 20:59 Go to next message
John G is currently offline John GFriend
Messages: 21
Registered: July 2009
Junior Member
Hello,
I am converting an existing system using Hibernate annotations to
EMF/Teneo. I have created the xsd, and successfully built the genmodel and
ecore. I noticed the ecore has the appropriate annotations, but the
genmodel doesn't have any annotations. When I generate the model code,
there are no annotations for Hibernate! How can I tell Teneo/EMF to pass
along the annotations to the model code?

Here is my original class with Hibernate annotations, in part:
...
@Entity
@Table(name = "Disease")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class DiseaseDB implements Serializable {

@Transient
private static final long serialVersionUID = -6140860463338994924L;

@Transient
private static final Logger LOG = Logger.getLogger(DiseaseDB.class);

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Basic
private Long id;

@Basic
private String title;

@Basic
private Double infectionForce;

@OneToMany(mappedBy = "disease", cascade = { CascadeType.ALL })
@OrderBy("ordinal")
private List<DiseaseStageDB> stages = new
java.util.ArrayList<DiseaseStageDB>();
...

Here's the xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="qq.mob.disease.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
targetNamespace="qq.mob.disease.xsd" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:complexType name="Diseases">
<xs:sequence>
<xs:element name="disease" type="Disease" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Disease">
<xs:annotation>
<xs:appinfo source="teneo.jpa">
@Entity
@Table(name="Disease")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
</xs:appinfo>
</xs:annotation>
<xs:sequence>
<xs:element name="title" type="xs:string">
<xs:annotation>
<xs:appinfo>@Basic</xs:appinfo>
<xs:documentation>name of disease spelled out</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="stages" type="DiseaseStage" maxOccurs="unbounded">
<xs:annotation>
<xs:appinfo source="teneo.jpa">@OneToMany(mappedBy = "disease",
cascade = CascadeType.ALL})
@OrderBy("ordinal")
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="force" type="xs:double">
<xs:annotation>
<xs:documentation>force of infection</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:long"/>
</xs:complexType>
<xs:complexType name="DiseaseStage">
<xs:annotation>
<xs:appinfo source="teneo.jpa">@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@Table(name="DiseaseStage")</xs:appinfo>
</xs:annotation>
<xs:sequence>
<xs:element name="code" type="xs:string">
<xs:annotation>
<xs:documentation>one character code</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="title" type="xs:string">
<xs:annotation>
<xs:documentation>name of stage spelled out</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="ordinal" type="xs:int">
<xs:annotation>
<xs:documentation>governs the order of progression through the
stages</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="duration" type="xs:int">
<xs:annotation>
<xs:documentation>value of -1 means forever</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="suseptable" type="xs:boolean">
<xs:annotation>
<xs:documentation>does this stage represent suseptable?</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="infected" type="xs:boolean">
<xs:annotation>
<xs:documentation>dose thai stage represent infected?</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="infectious" type="xs:boolean">
<xs:annotation>
<xs:documentation>does this stage represent infectious?</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="immune" type="xs:boolean">
<xs:annotation>
<xs:documentation>does this stage represent immune?</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="disease" type="xs:anyURI" ecore:opposite="stages"
ecore:reference="Disease">
<xs:annotation>
<xs:documentation>Disease this stage is part of.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:long"/>
</xs:complexType>
<xs:complexType name="PooledState">
<xs:sequence/>
</xs:complexType>
</xs:schema>
Re: Teneo passes annotations? [message #424669 is a reply to message #424668] Fri, 31 October 2008 21:34 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi John,
You can find the annotations in the generated PackageImpl class in the impl package. They are
defined as eannotations, so not as standard jpa/java annotations. When Teneo starts at runtime the
in-model annotations are converted to a hibernate mapping (is basically also what hibernate
annotations library does).

Btw, many annotations are created (in-memory) automatically by Teneo. For example basic is not
required, also inheritancestrategy single table is the default. OneToMany is often not required
(although if you want orderby you need to set it).

gr. Martin

John G wrote:
> Hello,
> I am converting an existing system using Hibernate annotations to
> EMF/Teneo. I have created the xsd, and successfully built the genmodel
> and ecore. I noticed the ecore has the appropriate annotations, but the
> genmodel doesn't have any annotations. When I generate the model code,
> there are no annotations for Hibernate! How can I tell Teneo/EMF to pass
> along the annotations to the model code?
>
> Here is my original class with Hibernate annotations, in part:
> ...
> @Entity
> @Table(name = "Disease")
> @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
> public class DiseaseDB implements Serializable {
>
> @Transient
> private static final long serialVersionUID = -6140860463338994924L;
>
> @Transient
> private static final Logger LOG = Logger.getLogger(DiseaseDB.class);
>
> @Id
> @GeneratedValue(strategy = GenerationType.AUTO)
> @Basic
> private Long id;
>
> @Basic
> private String title;
>
> @Basic
> private Double infectionForce;
>
> @OneToMany(mappedBy = "disease", cascade = { CascadeType.ALL })
> @OrderBy("ordinal")
> private List<DiseaseStageDB> stages = new
> java.util.ArrayList<DiseaseStageDB>();
> ...
>
> Here's the xsd:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns="qq.mob.disease.xsd"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> targetNamespace="qq.mob.disease.xsd" elementFormDefault="qualified"
> attributeFormDefault="unqualified">
> <xs:complexType name="Diseases">
> <xs:sequence>
> <xs:element name="disease" type="Disease"
> maxOccurs="unbounded"/>
> </xs:sequence>
> </xs:complexType>
> <xs:complexType name="Disease">
> <xs:annotation>
> <xs:appinfo source="teneo.jpa">
> @Entity
> @Table(name="Disease")
> @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
> </xs:appinfo>
> </xs:annotation>
> <xs:sequence>
> <xs:element name="title" type="xs:string">
> <xs:annotation>
> <xs:appinfo>@Basic</xs:appinfo>
> <xs:documentation>name of disease spelled
> out</xs:documentation>
> </xs:annotation>
> </xs:element>
> <xs:element name="stages" type="DiseaseStage"
> maxOccurs="unbounded">
> <xs:annotation>
> <xs:appinfo source="teneo.jpa">@OneToMany(mappedBy =
> "disease", cascade = CascadeType.ALL})
> @OrderBy("ordinal")
> </xs:appinfo>
> </xs:annotation>
> </xs:element>
> <xs:element name="force" type="xs:double">
> <xs:annotation>
> <xs:documentation>force of infection</xs:documentation>
> </xs:annotation>
> </xs:element>
> </xs:sequence>
> <xs:attribute name="id" type="xs:long"/>
> </xs:complexType>
> <xs:complexType name="DiseaseStage">
> <xs:annotation>
> <xs:appinfo source="teneo.jpa">@Entity
> @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
> @Table(name="DiseaseStage")</xs:appinfo>
> </xs:annotation>
> <xs:sequence>
> <xs:element name="code" type="xs:string">
> <xs:annotation>
> <xs:documentation>one character code</xs:documentation>
> </xs:annotation>
> </xs:element>
> <xs:element name="title" type="xs:string">
> <xs:annotation>
> <xs:documentation>name of stage spelled
> out</xs:documentation>
> </xs:annotation>
> </xs:element>
> <xs:element name="ordinal" type="xs:int">
> <xs:annotation>
> <xs:documentation>governs the order of progression
> through the stages</xs:documentation>
> </xs:annotation>
> </xs:element>
> <xs:element name="duration" type="xs:int">
> <xs:annotation>
> <xs:documentation>value of -1 means
> forever</xs:documentation>
> </xs:annotation>
> </xs:element>
> <xs:element name="suseptable" type="xs:boolean">
> <xs:annotation>
> <xs:documentation>does this stage represent
> suseptable?</xs:documentation>
> </xs:annotation>
> </xs:element>
> <xs:element name="infected" type="xs:boolean">
> <xs:annotation>
> <xs:documentation>dose thai stage represent
> infected?</xs:documentation>
> </xs:annotation>
> </xs:element>
> <xs:element name="infectious" type="xs:boolean">
> <xs:annotation>
> <xs:documentation>does this stage represent
> infectious?</xs:documentation>
> </xs:annotation>
> </xs:element>
> <xs:element name="immune" type="xs:boolean">
> <xs:annotation>
> <xs:documentation>does this stage represent
> immune?</xs:documentation>
> </xs:annotation>
> </xs:element>
> <xs:element name="disease" type="xs:anyURI"
> ecore:opposite="stages" ecore:reference="Disease">
> <xs:annotation>
> <xs:documentation>Disease this stage is part
> of.</xs:documentation>
> </xs:annotation>
> </xs:element>
> </xs:sequence>
> <xs:attribute name="id" type="xs:long"/>
> </xs:complexType>
> <xs:complexType name="PooledState">
> <xs:sequence/>
> </xs:complexType>
> </xs:schema>
>
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Teneo passes annotations? [message #424732 is a reply to message #424669] Mon, 03 November 2008 21:16 Go to previous message
John G is currently offline John GFriend
Messages: 21
Registered: July 2009
Junior Member
Thanks, Martin. That explains it.

John
Previous Topic:Re: Teneo Service Layer Design?
Next Topic:Soft Containment
Goto Forum:
  


Current Time: Fri Apr 26 13:41:34 GMT 2024

Powered by FUDForum. Page generated in 0.02878 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top