Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Issue with JPA Annotations
Issue with JPA Annotations [message #86214] Wed, 13 June 2007 15:29 Go to next message
No real name is currently offline No real nameFriend
Messages: 36
Registered: July 2009
Member
I am trying to capture JPA annotations in EMF editor (Soyatec) , generate
a code and then use Teneo to generate HBM file. It seems annotations are
not reflected in HBM file.

ecore annotation looks like :

<eClassifiers xsi:type="ecore:EClass" name="EQUser"
eSuperTypes="#//EQGlobalDomainObject">
<eAnnotations source="teneo.jpa">
<details key="appinfo" value="@Entity(name=t_eq_user)"/>
<details key="value" value="@Table(name=t_eq_user)"/>
</eAnnotations>

generated code has following comments :

@model annotation="teneo.jpa appinfo='@Entity(name=t_eq_user)'
value='@Table(name=t_eq_user)'"
@generated

But hibernate file doesnt have new table name :

<joined-subclass name="com.company.eqfc.model.orgdata.impl.EQUserImpl"
entity-name="EQUser" abstract="false" lazy="false"
extends="EQGlobalDomainObject" table="`equser`">

Can you pls help ?

Also how can we add multiple annotations through EMF editor ? it doesnt
allow multiple properties with 'appinfo' name ?
Re: Issue with JPA Annotations [message #86259 is a reply to message #86214] Wed, 13 June 2007 18:28 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Can you check if the annotations are present in the generated EPackageImpl java class?
If they are then maybe it is best that I try your ecore. If not then the problem is in the java
packageimpl generation.

When I edit the ecore model in the emf ecore editor then the Property view shows a value field when
I click on the button on the right then a multi-line text editor opens in which I can enter multiple
lines with annotations.

gr. Martin

Vaibhav Kulkarni wrote:
> I am trying to capture JPA annotations in EMF editor (Soyatec) ,
> generate a code and then use Teneo to generate HBM file. It seems
> annotations are not reflected in HBM file.
>
> ecore annotation looks like :
> <eClassifiers xsi:type="ecore:EClass" name="EQUser"
> eSuperTypes="#//EQGlobalDomainObject">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@Entity(name=t_eq_user)"/>
> <details key="value" value="@Table(name=t_eq_user)"/>
> </eAnnotations>
>
> generated code has following comments :
>
> @model annotation="teneo.jpa appinfo='@Entity(name=t_eq_user)'
> value='@Table(name=t_eq_user)'"
> @generated
> But hibernate file doesnt have new table name :
>
> <joined-subclass name="com.company.eqfc.model.orgdata.impl.EQUserImpl"
> entity-name="EQUser" abstract="false" lazy="false"
> extends="EQGlobalDomainObject" table="`equser`">
>
> Can you pls help ?
>
> Also how can we add multiple annotations through EMF editor ? it doesnt
> allow multiple properties with 'appinfo' name ?
>
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Issue with JPA Annotations [message #86304 is a reply to message #86259] Wed, 13 June 2007 18:58 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 36
Registered: July 2009
Member
I do see annotations in the Epackageimpl. Here is the method in the
package impl :

protected void createTeneoAnnotations() {
String source = "teneo.jpa";
addAnnotation
(jpaTableEClass,
source,
new String[] {
"appinfo", "@Entity(name=t_jpatable)"
});
}

Here is the Ecore file :

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="jpatest"
nsURI="http://com.jpmorgan.jpatest" nsPrefix="com.jpmorgan.jpatest">
<eClassifiers xsi:type="ecore:EClass" name="JPATable">
<eAnnotations source="teneo.jpa">
<details key="appinfo" value="@Entity(name=t_jpatable)"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
</ecore:EPackage>


Here is the HBM file generated from above ecore file :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<!-- Generated by Teneo on Wed Jun 13 12:32:01 EDT 2007 -->
<hibernate-mapping>
<class name="org.eclipse.emf.ecore.impl.DynamicEObjectImpl"
entity-name="JPATable" abstract="false" lazy="false" table="`jpatable`">

based on the annotation, table name in this case should be t_jpatable.

Appreciate your help.
Re: Issue with JPA Annotations [message #86347 is a reply to message #86304] Wed, 13 June 2007 20:23 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Here is the ecore which creates a table with the name test_jpatable. The name of the entity is not
picked up, this is a bug. The table annotation works.

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="jpatest"
nsURI="http://com.jpmorgan.jpatest" nsPrefix="com.jpmorgan.jpatest">
<eClassifiers xsi:type="ecore:EClass" name="JPATable">
<eAnnotations source="teneo.jpa">
<details key="appinfo" value="@Entity(name=&quot;t_jpatable&quot;)
&#xA;@Table(name=&quot;test_jpatable&quot;)"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType
http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
</ecore:EPackage>

gr. Martin

Vaibhav Kulkarni wrote:
> I do see annotations in the Epackageimpl. Here is the method in the
> package impl :
> protected void createTeneoAnnotations() {
> String source = "teneo.jpa";
> addAnnotation
> (jpaTableEClass, source, new String[] {
> "appinfo", "@Entity(name=t_jpatable)"
> });
> }
>
> Here is the Ecore file :
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="jpatest"
> nsURI="http://com.jpmorgan.jpatest" nsPrefix="com.jpmorgan.jpatest">
> <eClassifiers xsi:type="ecore:EClass" name="JPATable">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@Entity(name=t_jpatable)"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </eClassifiers>
> </ecore:EPackage>
>
>
> Here is the HBM file generated from above ecore file :
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
> 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
>
> <!-- Generated by Teneo on Wed Jun 13 12:32:01 EDT 2007 -->
> <hibernate-mapping>
> <class name="org.eclipse.emf.ecore.impl.DynamicEObjectImpl"
> entity-name="JPATable" abstract="false" lazy="false" table="`jpatable`">
>
> based on the annotation, table name in this case should be t_jpatable.
> Appreciate your help.
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Issue with JPA Annotations [message #86359 is a reply to message #86347] Wed, 13 June 2007 20:59 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 36
Registered: July 2009
Member
Martin

Thx for quick response.

Unfortunately its still not working for me. Not sure if there is something
wrong with my setup. This is what I did during retest :

1:- Edited ecore file and made changes as suggested by you.

i.e. <details key="appinfo"
value=" @Entity(name=&quot;t_jpatable&quot;)&#xA;@Table( name=&quot;test_jpatable&quot;) "/>

2. Reloaded this ecore in genmodel and generated code. Above change is
reflected in JpatestPackageImpl

protected void createTeneoAnnotations() {
String source = "teneo.jpa";
addAnnotation
(jpaTableEClass,
source,
new String[] {
"appinfo",
"@Entity(name=\"t_jpatable\")\n@Table(name=\"test_jpatable\")"
});
}

3. Right clicked on jpatest.ecore file and then ran Teneo -> Generate EMF
- Hibernate O/R Mapping

4. Hibernate mapping file is generated which doesnt have above table name.

<class name="com.jpmorgan.jpatest.impl.JPATableImpl"
entity-name="JPATable" abstract="false" lazy="false" table="`jpatable`">

I am using Teneo 0.8.0.

Any clue ??
Re: Issue with JPA Annotations [message #86372 is a reply to message #86359] Wed, 13 June 2007 21:08 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Okay, if you right click on the ecore file to create the hbm file then you don't need to re-generate
the java code, only if you use the hbdatastore without a hbm file then this is required.

Can you post the exact ecore you use or send me it by email?

gr. Martin

Vaibhav Kulkarni wrote:
> Martin
>
> Thx for quick response.
>
> Unfortunately its still not working for me. Not sure if there is
> something wrong with my setup. This is what I did during retest :
>
> 1:- Edited ecore file and made changes as suggested by you.
>
> i.e. <details key="appinfo"
> value=" @Entity(name=&quot;t_jpatable&quot;)&#xA;@Table( name=&quot;test_jpatable&quot;) "/>
>
>
> 2. Reloaded this ecore in genmodel and generated code. Above change is
> reflected in JpatestPackageImpl
>
> protected void createTeneoAnnotations() {
> String source = "teneo.jpa";
> addAnnotation
> (jpaTableEClass, source, new String[] {
> "appinfo",
> "@Entity(name=\"t_jpatable\")\n@Table(name=\"test_jpatable\")"
> });
> }
>
> 3. Right clicked on jpatest.ecore file and then ran Teneo -> Generate
> EMF - Hibernate O/R Mapping
>
> 4. Hibernate mapping file is generated which doesnt have above table name.
>
> <class name="com.jpmorgan.jpatest.impl.JPATableImpl"
> entity-name="JPATable" abstract="false" lazy="false" table="`jpatable`">
>
> I am using Teneo 0.8.0.
> Any clue ??
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Issue with JPA Annotations [message #86387 is a reply to message #86372] Wed, 13 June 2007 21:35 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 36
Registered: July 2009
Member
Here is the complete ecore file :

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="jpatest"
nsURI="http://com.jpmorgan.jpatest" nsPrefix="com.jpmorgan.jpatest">
<eClassifiers xsi:type="ecore:EClass" name="JPATable">
<eAnnotations source="teneo.jpa">
<details key="appinfo"
value=" @Entity(name=&quot;t_jpatable&quot;)&#xA;@Table( name=&quot;test_jpatable&quot;) "/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
</ecore:EPackage>
Re: Issue with JPA Annotations [message #86401 is a reply to message #86387] Wed, 13 June 2007 23:02 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
This works for me but for testing I do not use the right click but use the HbDataStore (and then
call getMappingXML). Although the underlying code for the right-click menu option is the same as the
one used in the HbDataStore.

Can you try programmatically (initialize a hbdatastore)?

Here is the hbm I get:

<!-- Generated by Teneo on Thu Jun 14 01:01:21 CEST 2007 -->
<hibernate-mapping>
<class name="org.eclipse.emf.ecore.impl.DynamicEObjectImpl" entity-name="JPATable" abstract="false"
lazy="false" discriminator-value="t_jpatable" table="`test_jpatable`">
<meta attribute="eclassName">JPATable</meta>
<meta attribute="epackage">http://com.jpmorgan.jpatest</meta>
<id type="long" name="e_id" column="e_id"
access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
<meta attribute="syntheticId">true</meta>
<generator class="native"/>
</id>
<discriminator column="`dtype`" type="string"/>
<version name="e_version" column="e_version"
access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
<meta attribute="syntheticVersion">true</meta>
</version>
<property name="name" lazy="false" insert="true" update="true" not-null="false" unique="false"
type="java.lang.String">
<column not-null="false" unique="false" name="`name`"/>
</property>
</class>
</hibernate-mapping>

gr. Martin

Vaibhav Kulkarni wrote:
> Here is the complete ecore file :
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="jpatest"
> nsURI="http://com.jpmorgan.jpatest" nsPrefix="com.jpmorgan.jpatest">
> <eClassifiers xsi:type="ecore:EClass" name="JPATable">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo"
> value=" @Entity(name=&quot;t_jpatable&quot;)&#xA;@Table( name=&quot;test_jpatable&quot;) "/>
>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </eClassifiers>
> </ecore:EPackage>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Issue with JPA Annotations [message #86417 is a reply to message #86401] Thu, 14 June 2007 01:41 Go to previous message
No real name is currently offline No real nameFriend
Messages: 36
Registered: July 2009
Member
Martin

This works. That means there is some difference between the way hbm file
is generated from Epackage or Ecore. Epackage works as annotations are
added to Eclass. In case of Ecore I think it fails to interpret
eAnnotations from XML file.

One question. Can HbDataStore be initialized based on ecore ? If yes then
we can try to see if that works.

Many thanks for your quick help. Also let me know when next version of
Teneo will be available.
Re: Issue with JPA Annotations [message #606950 is a reply to message #86214] Wed, 13 June 2007 18:28 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Can you check if the annotations are present in the generated EPackageImpl java class?
If they are then maybe it is best that I try your ecore. If not then the problem is in the java
packageimpl generation.

When I edit the ecore model in the emf ecore editor then the Property view shows a value field when
I click on the button on the right then a multi-line text editor opens in which I can enter multiple
lines with annotations.

gr. Martin

Vaibhav Kulkarni wrote:
> I am trying to capture JPA annotations in EMF editor (Soyatec) ,
> generate a code and then use Teneo to generate HBM file. It seems
> annotations are not reflected in HBM file.
>
> ecore annotation looks like :
> <eClassifiers xsi:type="ecore:EClass" name="EQUser"
> eSuperTypes="#//EQGlobalDomainObject">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@Entity(name=t_eq_user)"/>
> <details key="value" value="@Table(name=t_eq_user)"/>
> </eAnnotations>
>
> generated code has following comments :
>
> @model annotation="teneo.jpa appinfo='@Entity(name=t_eq_user)'
> value='@Table(name=t_eq_user)'"
> @generated
> But hibernate file doesnt have new table name :
>
> <joined-subclass name="com.company.eqfc.model.orgdata.impl.EQUserImpl"
> entity-name="EQUser" abstract="false" lazy="false"
> extends="EQGlobalDomainObject" table="`equser`">
>
> Can you pls help ?
>
> Also how can we add multiple annotations through EMF editor ? it doesnt
> allow multiple properties with 'appinfo' name ?
>
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Issue with JPA Annotations [message #606956 is a reply to message #86259] Wed, 13 June 2007 18:58 Go to previous message
No real name is currently offline No real nameFriend
Messages: 36
Registered: July 2009
Member
I do see annotations in the Epackageimpl. Here is the method in the
package impl :

protected void createTeneoAnnotations() {
String source = "teneo.jpa";
addAnnotation
(jpaTableEClass,
source,
new String[] {
"appinfo", "@Entity(name=t_jpatable)"
});
}

Here is the Ecore file :

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="jpatest"
nsURI="http://com.jpmorgan.jpatest" nsPrefix="com.jpmorgan.jpatest">
<eClassifiers xsi:type="ecore:EClass" name="JPATable">
<eAnnotations source="teneo.jpa">
<details key="appinfo" value="@Entity(name=t_jpatable)"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
</ecore:EPackage>


Here is the HBM file generated from above ecore file :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<!-- Generated by Teneo on Wed Jun 13 12:32:01 EDT 2007 -->
<hibernate-mapping>
<class name="org.eclipse.emf.ecore.impl.DynamicEObjectImpl"
entity-name="JPATable" abstract="false" lazy="false" table="`jpatable`">

based on the annotation, table name in this case should be t_jpatable.

Appreciate your help.
Re: Issue with JPA Annotations [message #606966 is a reply to message #86304] Wed, 13 June 2007 20:23 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Here is the ecore which creates a table with the name test_jpatable. The name of the entity is not
picked up, this is a bug. The table annotation works.

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="jpatest"
nsURI="http://com.jpmorgan.jpatest" nsPrefix="com.jpmorgan.jpatest">
<eClassifiers xsi:type="ecore:EClass" name="JPATable">
<eAnnotations source="teneo.jpa">
<details key="appinfo" value="@Entity(name=&quot;t_jpatable&quot;)
&#xA;@Table(name=&quot;test_jpatable&quot;)"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType
http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
</ecore:EPackage>

gr. Martin

Vaibhav Kulkarni wrote:
> I do see annotations in the Epackageimpl. Here is the method in the
> package impl :
> protected void createTeneoAnnotations() {
> String source = "teneo.jpa";
> addAnnotation
> (jpaTableEClass, source, new String[] {
> "appinfo", "@Entity(name=t_jpatable)"
> });
> }
>
> Here is the Ecore file :
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="jpatest"
> nsURI="http://com.jpmorgan.jpatest" nsPrefix="com.jpmorgan.jpatest">
> <eClassifiers xsi:type="ecore:EClass" name="JPATable">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@Entity(name=t_jpatable)"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </eClassifiers>
> </ecore:EPackage>
>
>
> Here is the HBM file generated from above ecore file :
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
> 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
>
> <!-- Generated by Teneo on Wed Jun 13 12:32:01 EDT 2007 -->
> <hibernate-mapping>
> <class name="org.eclipse.emf.ecore.impl.DynamicEObjectImpl"
> entity-name="JPATable" abstract="false" lazy="false" table="`jpatable`">
>
> based on the annotation, table name in this case should be t_jpatable.
> Appreciate your help.
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Issue with JPA Annotations [message #606969 is a reply to message #86347] Wed, 13 June 2007 20:59 Go to previous message
No real name is currently offline No real nameFriend
Messages: 36
Registered: July 2009
Member
Martin

Thx for quick response.

Unfortunately its still not working for me. Not sure if there is something
wrong with my setup. This is what I did during retest :

1:- Edited ecore file and made changes as suggested by you.

i.e. <details key="appinfo"
value=" @Entity(name=&quot;t_jpatable&quot;)&#xA;@Table( name=&quot;test_jpatable&quot;) "/>

2. Reloaded this ecore in genmodel and generated code. Above change is
reflected in JpatestPackageImpl

protected void createTeneoAnnotations() {
String source = "teneo.jpa";
addAnnotation
(jpaTableEClass,
source,
new String[] {
"appinfo",
"@Entity(name=\"t_jpatable\")\n@Table(name=\"test_jpatable\")"
});
}

3. Right clicked on jpatest.ecore file and then ran Teneo -> Generate EMF
- Hibernate O/R Mapping

4. Hibernate mapping file is generated which doesnt have above table name.

<class name="com.jpmorgan.jpatest.impl.JPATableImpl"
entity-name="JPATable" abstract="false" lazy="false" table="`jpatable`">

I am using Teneo 0.8.0.

Any clue ??
Re: Issue with JPA Annotations [message #606971 is a reply to message #86359] Wed, 13 June 2007 21:08 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Okay, if you right click on the ecore file to create the hbm file then you don't need to re-generate
the java code, only if you use the hbdatastore without a hbm file then this is required.

Can you post the exact ecore you use or send me it by email?

gr. Martin

Vaibhav Kulkarni wrote:
> Martin
>
> Thx for quick response.
>
> Unfortunately its still not working for me. Not sure if there is
> something wrong with my setup. This is what I did during retest :
>
> 1:- Edited ecore file and made changes as suggested by you.
>
> i.e. <details key="appinfo"
> value=" @Entity(name=&quot;t_jpatable&quot;)&#xA;@Table( name=&quot;test_jpatable&quot;) "/>
>
>
> 2. Reloaded this ecore in genmodel and generated code. Above change is
> reflected in JpatestPackageImpl
>
> protected void createTeneoAnnotations() {
> String source = "teneo.jpa";
> addAnnotation
> (jpaTableEClass, source, new String[] {
> "appinfo",
> "@Entity(name=\"t_jpatable\")\n@Table(name=\"test_jpatable\")"
> });
> }
>
> 3. Right clicked on jpatest.ecore file and then ran Teneo -> Generate
> EMF - Hibernate O/R Mapping
>
> 4. Hibernate mapping file is generated which doesnt have above table name.
>
> <class name="com.jpmorgan.jpatest.impl.JPATableImpl"
> entity-name="JPATable" abstract="false" lazy="false" table="`jpatable`">
>
> I am using Teneo 0.8.0.
> Any clue ??
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Issue with JPA Annotations [message #606973 is a reply to message #86372] Wed, 13 June 2007 21:35 Go to previous message
No real name is currently offline No real nameFriend
Messages: 36
Registered: July 2009
Member
Here is the complete ecore file :

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="jpatest"
nsURI="http://com.jpmorgan.jpatest" nsPrefix="com.jpmorgan.jpatest">
<eClassifiers xsi:type="ecore:EClass" name="JPATable">
<eAnnotations source="teneo.jpa">
<details key="appinfo"
value=" @Entity(name=&quot;t_jpatable&quot;)&#xA;@Table( name=&quot;test_jpatable&quot;) "/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
</ecore:EPackage>
Re: Issue with JPA Annotations [message #606975 is a reply to message #86387] Wed, 13 June 2007 23:02 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
This works for me but for testing I do not use the right click but use the HbDataStore (and then
call getMappingXML). Although the underlying code for the right-click menu option is the same as the
one used in the HbDataStore.

Can you try programmatically (initialize a hbdatastore)?

Here is the hbm I get:

<!-- Generated by Teneo on Thu Jun 14 01:01:21 CEST 2007 -->
<hibernate-mapping>
<class name="org.eclipse.emf.ecore.impl.DynamicEObjectImpl" entity-name="JPATable" abstract="false"
lazy="false" discriminator-value="t_jpatable" table="`test_jpatable`">
<meta attribute="eclassName">JPATable</meta>
<meta attribute="epackage">http://com.jpmorgan.jpatest</meta>
<id type="long" name="e_id" column="e_id"
access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
<meta attribute="syntheticId">true</meta>
<generator class="native"/>
</id>
<discriminator column="`dtype`" type="string"/>
<version name="e_version" column="e_version"
access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
<meta attribute="syntheticVersion">true</meta>
</version>
<property name="name" lazy="false" insert="true" update="true" not-null="false" unique="false"
type="java.lang.String">
<column not-null="false" unique="false" name="`name`"/>
</property>
</class>
</hibernate-mapping>

gr. Martin

Vaibhav Kulkarni wrote:
> Here is the complete ecore file :
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="jpatest"
> nsURI="http://com.jpmorgan.jpatest" nsPrefix="com.jpmorgan.jpatest">
> <eClassifiers xsi:type="ecore:EClass" name="JPATable">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo"
> value=" @Entity(name=&quot;t_jpatable&quot;)&#xA;@Table( name=&quot;test_jpatable&quot;) "/>
>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </eClassifiers>
> </ecore:EPackage>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Issue with JPA Annotations [message #606977 is a reply to message #86401] Thu, 14 June 2007 01:41 Go to previous message
No real name is currently offline No real nameFriend
Messages: 36
Registered: July 2009
Member
Martin

This works. That means there is some difference between the way hbm file
is generated from Epackage or Ecore. Epackage works as annotations are
added to Eclass. In case of Ecore I think it fails to interpret
eAnnotations from XML file.

One question. Can HbDataStore be initialized based on ecore ? If yes then
we can try to see if that works.

Many thanks for your quick help. Also let me know when next version of
Teneo will be available.
Previous Topic:[teneo] primary key in java code
Next Topic:[Teneo / JPOX] Generate EMF JDO/JPOX OR Mapping
Goto Forum:
  


Current Time: Mon Jan 18 09:05:55 GMT 2021

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

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

Back to the top