|
Re: Teneo passes annotations? [message #424669 is a reply to message #424668] |
Fri, 31 October 2008 21:34 |
Martin Taal 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
|
|
|
|
Powered by
FUDForum. Page generated in 0.02878 seconds