Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [TENEO] Issues when loading models from an already existing Teneo database or deleting them
[TENEO] Issues when loading models from an already existing Teneo database or deleting them [message #98150] Mon, 01 October 2007 15:48 Go to next message
Eclipse UserFriend
Originally posted by: Hugo.Bruneliere.univ-nantes.fr

Hi,

I'm using Teneo in order to provide a database-based implementation of
the AM3 model repository generic interface (see
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.gmt/AM3 /plugins/org.eclipse.gmt.am3.core/src/org/eclipse/gmt/am3/co re/storage/?root=Technology_Project).

I don't (or at least I don't seem to) have problems when adding,
retrieving or deleting metamodels (i.e. EPackages) into/from the repository.

However, I'm facing some issues when trying to do the same thing with
terminal models conforming to loaded metamodels (i.e. EObjects which are
instances of EClasses contained in previously loaded EPackages). For
both issues, I have already checked that the models stored into the EMF
resources are correct.


1) When calling
" this.getHibernateDataStoreSession().delete(res.getContents() .get(0)); "
with "res" the EMF resource storing the terminal model, the following
exception is raised:

org.eclipse.gmt.am3.core.storage.RepositoryException:
org.hibernate.NonUniqueObjectException: a different object with the same
identifier value was already associated with the session: [Deb#2]
at
org.eclipse.gmt.am3.repository.teneo.TeneoRepository.removeM odel(TeneoRepository.java:487)
at
org.eclipse.gmt.am3.repository.teneo.testrepository.main(tes trepository.java:178)
Caused by: org.hibernate.NonUniqueObjectException: a different object
with the same identifier value was already associated with the session:
[Deb#2]
at
org.hibernate.engine.StatefulPersistenceContext.checkUniquen ess(StatefulPersistenceContext.java:556)
at
org.hibernate.event.def.DefaultDeleteEventListener.onDelete( DefaultDeleteEventListener.java:88)
at
org.hibernate.event.def.DefaultDeleteEventListener.onDelete( DefaultDeleteEventListener.java:49)
at org.hibernate.impl.SessionImpl.fireDelete(SessionImpl.java:7 66)
at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:744)
at
org.eclipse.emf.teneo.hibernate.HbSessionWrapper.delete(HbSe ssionWrapper.java:156)

As a consequence, the EObjects composing the model are still stored into
the database. Maybe this issue is one of the causes of the next problem
but I'm not sure of that!


2) When working on a database which has been previously created (by
another session) and trying to add a new terminal model (which conforms
to an already stored metamodel), from
" this.getHibernateDataStoreSession().saveOrUpdate(res.getCont ents().get(0)); "
I got:

org.eclipse.gmt.am3.core.storage.RepositoryException:
java.lang.IllegalArgumentException: No annotated model element present
for: Deb for type EClass has its epackage been registered with Teneo?
at
org.eclipse.gmt.am3.repository.teneo.TeneoRepository.addMode l(TeneoRepository.java:413)
at
org.eclipse.gmt.am3.repository.teneo.TeneoRepository.updateM odel(TeneoRepository.java:439)
at
org.eclipse.gmt.am3.repository.teneo.TeneoRepository.updateM odel(TeneoRepository.java:464)
at
org.eclipse.gmt.am3.repository.teneo.testrepository.main(tes trepository.java:127)
Caused by: java.lang.IllegalArgumentException: No annotated model
element present for: Deb for type EClass has its epackage been
registered with Teneo?
at
org.eclipse.emf.teneo.annotations.pamodel.impl.PAnnotatedMod elImpl.checkAnnotatedPresent(PAnnotatedModelImpl.java:337)
at
org.eclipse.emf.teneo.annotations.pamodel.impl.PAnnotatedMod elImpl.getPAnnotated(PAnnotatedModelImpl.java:279)
at
org.eclipse.emf.teneo.mapping.strategy.impl.EntityResolvingN ameStrategy.toEntityName(EntityResolvingNameStrategy.java:84 )
at
org.eclipse.emf.teneo.hibernate.EMFInterceptor.getEntityName (EMFInterceptor.java:75)
at org.hibernate.impl.SessionImpl.guessEntityName(SessionImpl.j ava:1765)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImp l.java:1338)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.jav a:180)
at
org.hibernate.event.def.AbstractSaveEventListener.getEntityS tate(AbstractSaveEventListener.java:487)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:84)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:507)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :499)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :495)
at
org.eclipse.emf.teneo.hibernate.HbSessionWrapper.saveOrUpdat e(HbSessionWrapper.java:151)

What is strange is that I'm succeeding in retrieving the corresponding
metamodel (i.e. EPackages)...


Does anybody have ideas about where do these problems come from and how
to solve them?

Best regards,

Hugo

--
--------------------------------------------------------
Hugo Bruneliere - R&D Engineer
ATLAS Group (INRIA & LINA) - University of Nantes
2, rue de la Houssiniere
44322 Nantes Cedex 3 - France
office +33 2 51 12 58 10 /\ cell.+33 6 07 42 45 30
EMail: Hugo.Bruneliere@univ-nantes.fr
http://www.sciences.univ-nantes.fr/lina/atl/
--------------------------------------------------------
Re: [TENEO] Issues when loading models from an already existing Teneo database or deleting them [message #98211 is a reply to message #98150] Mon, 01 October 2007 21:24 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Hugo,
1) this can occur if you have a type which has an id which you assign 'manually' (not generated by
the db). If two different instances of the same type have the same id then this error occurs.
2) Using an example, what I understand is that you store an EPackage P1 with an eClass C1 in the db
and then try to store an eobject which has this eclass c1 in the same db?
Did you pass P1 as an epackage to the hibernatedatastore (hbdatastore.setEPackages(...))?

gr. Martin

Hugo Bruneliere wrote:
> Hi,
>
> I'm using Teneo in order to provide a database-based implementation of
> the AM3 model repository generic interface (see
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.gmt/AM3 /plugins/org.eclipse.gmt.am3.core/src/org/eclipse/gmt/am3/co re/storage/?root=Technology_Project).
>
>
> I don't (or at least I don't seem to) have problems when adding,
> retrieving or deleting metamodels (i.e. EPackages) into/from the
> repository.
>
> However, I'm facing some issues when trying to do the same thing with
> terminal models conforming to loaded metamodels (i.e. EObjects which are
> instances of EClasses contained in previously loaded EPackages). For
> both issues, I have already checked that the models stored into the EMF
> resources are correct.
>
>
> 1) When calling
> " this.getHibernateDataStoreSession().delete(res.getContents() .get(0)); "
> with "res" the EMF resource storing the terminal model, the following
> exception is raised:
>
> org.eclipse.gmt.am3.core.storage.RepositoryException:
> org.hibernate.NonUniqueObjectException: a different object with the same
> identifier value was already associated with the session: [Deb#2]
> at
> org.eclipse.gmt.am3.repository.teneo.TeneoRepository.removeM odel(TeneoRepository.java:487)
>
> at
> org.eclipse.gmt.am3.repository.teneo.testrepository.main(tes trepository.java:178)
>
> Caused by: org.hibernate.NonUniqueObjectException: a different object
> with the same identifier value was already associated with the session:
> [Deb#2]
> at
> org.hibernate.engine.StatefulPersistenceContext.checkUniquen ess(StatefulPersistenceContext.java:556)
>
> at
> org.hibernate.event.def.DefaultDeleteEventListener.onDelete( DefaultDeleteEventListener.java:88)
>
> at
> org.hibernate.event.def.DefaultDeleteEventListener.onDelete( DefaultDeleteEventListener.java:49)
>
> at org.hibernate.impl.SessionImpl.fireDelete(SessionImpl.java:7 66)
> at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:744)
> at
> org.eclipse.emf.teneo.hibernate.HbSessionWrapper.delete(HbSe ssionWrapper.java:156)
>
>
> As a consequence, the EObjects composing the model are still stored into
> the database. Maybe this issue is one of the causes of the next problem
> but I'm not sure of that!
>
>
> 2) When working on a database which has been previously created (by
> another session) and trying to add a new terminal model (which conforms
> to an already stored metamodel), from
> " this.getHibernateDataStoreSession().saveOrUpdate(res.getCont ents().get(0)); "
> I got:
>
> org.eclipse.gmt.am3.core.storage.RepositoryException:
> java.lang.IllegalArgumentException: No annotated model element present
> for: Deb for type EClass has its epackage been registered with Teneo?
> at
> org.eclipse.gmt.am3.repository.teneo.TeneoRepository.addMode l(TeneoRepository.java:413)
>
> at
> org.eclipse.gmt.am3.repository.teneo.TeneoRepository.updateM odel(TeneoRepository.java:439)
>
> at
> org.eclipse.gmt.am3.repository.teneo.TeneoRepository.updateM odel(TeneoRepository.java:464)
>
> at
> org.eclipse.gmt.am3.repository.teneo.testrepository.main(tes trepository.java:127)
>
> Caused by: java.lang.IllegalArgumentException: No annotated model
> element present for: Deb for type EClass has its epackage been
> registered with Teneo?
> at
> org.eclipse.emf.teneo.annotations.pamodel.impl.PAnnotatedMod elImpl.checkAnnotatedPresent(PAnnotatedModelImpl.java:337)
>
> at
> org.eclipse.emf.teneo.annotations.pamodel.impl.PAnnotatedMod elImpl.getPAnnotated(PAnnotatedModelImpl.java:279)
>
> at
> org.eclipse.emf.teneo.mapping.strategy.impl.EntityResolvingN ameStrategy.toEntityName(EntityResolvingNameStrategy.java:84 )
>
> at
> org.eclipse.emf.teneo.hibernate.EMFInterceptor.getEntityName (EMFInterceptor.java:75)
>
> at
> org.hibernate.impl.SessionImpl.guessEntityName(SessionImpl.j ava:1765)
> at
> org.hibernate.impl.SessionImpl.getEntityPersister(SessionImp l.java:1338)
> at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.jav a:180)
> at
> org.hibernate.event.def.AbstractSaveEventListener.getEntityS tate(AbstractSaveEventListener.java:487)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:84)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>
> at
> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:507)
> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :499)
> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :495)
> at
> org.eclipse.emf.teneo.hibernate.HbSessionWrapper.saveOrUpdat e(HbSessionWrapper.java:151)
>
>
> What is strange is that I'm succeeding in retrieving the corresponding
> metamodel (i.e. EPackages)...
>
>
> Does anybody have ideas about where do these problems come from and how
> to solve them?
>
> Best regards,
>
> Hugo
>


--

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: [TENEO] Issues when loading models from an already existing Teneo database or deleting them [message #98328 is a reply to message #98211] Tue, 02 October 2007 15:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Hugo.Bruneliere.univ-nantes.fr

Hi Martin,

Thanks for your answers, they helped me finding where my problems came
from ;-)

Best regards,

Hugo

Martin Taal a écrit :
> Hi Hugo,
> 1) this can occur if you have a type which has an id which you assign
> 'manually' (not generated by the db). If two different instances of the
> same type have the same id then this error occurs.
> 2) Using an example, what I understand is that you store an EPackage P1
> with an eClass C1 in the db and then try to store an eobject which has
> this eclass c1 in the same db?
> Did you pass P1 as an epackage to the hibernatedatastore
> (hbdatastore.setEPackages(...))?
>
> gr. Martin
>
> Hugo Bruneliere wrote:
>> Hi,
>>
>> I'm using Teneo in order to provide a database-based implementation of
>> the AM3 model repository generic interface (see
>> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.gmt/AM3 /plugins/org.eclipse.gmt.am3.core/src/org/eclipse/gmt/am3/co re/storage/?root=Technology_Project).
>>
>>
>> I don't (or at least I don't seem to) have problems when adding,
>> retrieving or deleting metamodels (i.e. EPackages) into/from the
>> repository.
>>
>> However, I'm facing some issues when trying to do the same thing with
>> terminal models conforming to loaded metamodels (i.e. EObjects which
>> are instances of EClasses contained in previously loaded EPackages).
>> For both issues, I have already checked that the models stored into
>> the EMF resources are correct.
>>
>>
>> 1) When calling
>> " this.getHibernateDataStoreSession().delete(res.getContents() .get(0)); "
>> with "res" the EMF resource storing the terminal model, the following
>> exception is raised:
>>
>> org.eclipse.gmt.am3.core.storage.RepositoryException:
>> org.hibernate.NonUniqueObjectException: a different object with the
>> same identifier value was already associated with the session: [Deb#2]
>> at
>> org.eclipse.gmt.am3.repository.teneo.TeneoRepository.removeM odel(TeneoRepository.java:487)
>>
>> at
>> org.eclipse.gmt.am3.repository.teneo.testrepository.main(tes trepository.java:178)
>>
>> Caused by: org.hibernate.NonUniqueObjectException: a different object
>> with the same identifier value was already associated with the
>> session: [Deb#2]
>> at
>> org.hibernate.engine.StatefulPersistenceContext.checkUniquen ess(StatefulPersistenceContext.java:556)
>>
>> at
>> org.hibernate.event.def.DefaultDeleteEventListener.onDelete( DefaultDeleteEventListener.java:88)
>>
>> at
>> org.hibernate.event.def.DefaultDeleteEventListener.onDelete( DefaultDeleteEventListener.java:49)
>>
>> at org.hibernate.impl.SessionImpl.fireDelete(SessionImpl.java:7 66)
>> at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:744)
>> at
>> org.eclipse.emf.teneo.hibernate.HbSessionWrapper.delete(HbSe ssionWrapper.java:156)
>>
>>
>> As a consequence, the EObjects composing the model are still stored
>> into the database. Maybe this issue is one of the causes of the next
>> problem but I'm not sure of that!
>>
>>
>> 2) When working on a database which has been previously created (by
>> another session) and trying to add a new terminal model (which
>> conforms to an already stored metamodel), from
>> " this.getHibernateDataStoreSession().saveOrUpdate(res.getCont ents().get(0)); "
>> I got:
>>
>> org.eclipse.gmt.am3.core.storage.RepositoryException:
>> java.lang.IllegalArgumentException: No annotated model element present
>> for: Deb for type EClass has its epackage been registered with Teneo?
>> at
>> org.eclipse.gmt.am3.repository.teneo.TeneoRepository.addMode l(TeneoRepository.java:413)
>>
>> at
>> org.eclipse.gmt.am3.repository.teneo.TeneoRepository.updateM odel(TeneoRepository.java:439)
>>
>> at
>> org.eclipse.gmt.am3.repository.teneo.TeneoRepository.updateM odel(TeneoRepository.java:464)
>>
>> at
>> org.eclipse.gmt.am3.repository.teneo.testrepository.main(tes trepository.java:127)
>>
>> Caused by: java.lang.IllegalArgumentException: No annotated model
>> element present for: Deb for type EClass has its epackage been
>> registered with Teneo?
>> at
>> org.eclipse.emf.teneo.annotations.pamodel.impl.PAnnotatedMod elImpl.checkAnnotatedPresent(PAnnotatedModelImpl.java:337)
>>
>> at
>> org.eclipse.emf.teneo.annotations.pamodel.impl.PAnnotatedMod elImpl.getPAnnotated(PAnnotatedModelImpl.java:279)
>>
>> at
>> org.eclipse.emf.teneo.mapping.strategy.impl.EntityResolvingN ameStrategy.toEntityName(EntityResolvingNameStrategy.java:84 )
>>
>> at
>> org.eclipse.emf.teneo.hibernate.EMFInterceptor.getEntityName (EMFInterceptor.java:75)
>>
>> at
>> org.hibernate.impl.SessionImpl.guessEntityName(SessionImpl.j ava:1765)
>> at
>> org.hibernate.impl.SessionImpl.getEntityPersister(SessionImp l.java:1338)
>> at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.jav a:180)
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.getEntityS tate(AbstractSaveEventListener.java:487)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:84)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>>
>> at
>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:507)
>> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :499)
>> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :495)
>> at
>> org.eclipse.emf.teneo.hibernate.HbSessionWrapper.saveOrUpdat e(HbSessionWrapper.java:151)
>>
>>
>> What is strange is that I'm succeeding in retrieving the corresponding
>> metamodel (i.e. EPackages)...
>>
>>
>> Does anybody have ideas about where do these problems come from and
>> how to solve them?
>>
>> Best regards,
>>
>> Hugo
>>
>
>


--
--------------------------------------------------------
Hugo Bruneliere - R&D Engineer
ATLAS Group (INRIA & LINA) - University of Nantes
2, rue de la Houssiniere
44322 Nantes Cedex 3 - France
office +33 2 51 12 58 10 /\ cell.+33 6 07 42 45 30
EMail: Hugo.Bruneliere@univ-nantes.fr
http://www.sciences.univ-nantes.fr/lina/atl/
--------------------------------------------------------
Re: [TENEO] Issues when loading models from an already existing Teneo database o [message #100452 is a reply to message #98150] Wed, 31 October 2007 18:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mduduzi.keswa.isizwe.com

Hi,
I have been trying to figure out a way to store ecore metamodel in a
database instead of the file based approach. I'm currently prototyping
using storing EObjects into a database using Teneo-Hibernate interface.
Will this (mentioned in this post) plugin/tool allow me to do such? Is
this part of Teneo-Hibernate interface. I'd appreciate it if I can be
pointed to an example or a detailed explanation on how to go about doing
this - at least to get started.

Thanks,
-Mdu
Re: [TENEO] Issues when loading models from an already existing Teneo database o [message #100465 is a reply to message #100452] Wed, 31 October 2007 18:24 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Mdu,
If you mean Teneo as the tool/plugin then Teneo should get pretty far in persisting ecore models
itself. I have only tried it for demo purposes and small testcases.

Here is part of a test case I have used to re-produce an issue someone had persisting ecore models.
I copied and pasted it and reformatted is it may not be syntactically correct but you get the meaning:

HbDataStore hbds = HbHelper.INSTANCE.createRegisterDataStore("test");
final Properties props = new Properties();

// here set your hibernate properties (jdbc url, etc.)
// hbds.setHibernateProperties(props);

// here set your teneo properties for example:
// props.setProperty(PersistenceOptions.INHERITANCE_MAPPING, "JOINED");
// props.put(PersistenceOptions.JOIN_TABLE_NAMING_STRATEGY, "ejb3");
// props.put(PersistenceOptions.JOIN_TABLE_FOR_NON_CONTAINED_AS SOCIATIONS, "true");
// hbds.setPersistenceProperties(props);

// sets the epackages stored in this datastore
hbds.setEPackages(new EPackage[] { EcorePackage.eINSTANCE, XMLTypePackage.eINSTANCE });

// create the db/tables
hbds.initialize();

// now store some epackages
Session s = hbds.getSessionFactory().openSession();
s.beginTransaction();

// the epacks list contains the EPackages you want to persist
for (EPackage epack : epacks) {
s.save(epack);
}
s.getTransaction().commit();

// now for test purposes read them back and put them in an array
s = hbds.getSessionFactory().openSession();
final List l = s.createQuery("select e from ecore.EPackage e").list();
final EPackage[] newEpacks = new EPackage[l.size()];
int i = 0;
for (Object o : l) {
final EPackage epack = (EPackage) o;
newEpacks[i++] = epack;
}

gr. Martin

Mdu Keswa wrote:
> Hi,
> I have been trying to figure out a way to store ecore metamodel in a
> database instead of the file based approach. I'm currently prototyping
> using storing EObjects into a database using Teneo-Hibernate interface.
> Will this (mentioned in this post) plugin/tool allow me to do such? Is
> this part of Teneo-Hibernate interface. I'd appreciate it if I can be
> pointed to an example or a detailed explanation on how to go about doing
> this - at least to get started.
>
> Thanks,
> -Mdu
>


--

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: [TENEO] Issues when loading models from an already existing Teneo database o [message #100478 is a reply to message #100465] Thu, 01 November 2007 10:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mduduzi.keswa.isizwe.com

Martin,
Brilliant! This is a great start for me. Maybe I have missed a
Teneo-Hibernate cookbook somewhere. Basically, ultimately I want to be
able to support at least the following use cases with help of
Teneo-Hibernate:

1. Start with annotized java interfaces to generate Ecore metamodel.
2. Store generated Ecore metamodel in a database (via Hibernate).
3. Load a metamodel from a database in 2. to generate objects to be stored
in the database.
4. Using a web based(Ajax) Editor and via Eclipse Editor modify metamodel
in 2.
4.1. Support for 'Entity Editor' so that end user with proper roles can
add attributes and maybe relationships to an existing entity/metamodel
5. Support to develop a web based (Ajax) Form Builder driven by querying
an existing Ecore metamodel from the database.
6. Support for Audit Trails whenever an object/entity (EObject) incurs
C.R.U.D. (Create,Read,Update,Delete) events

Maybe it's because Christmas is almost here but the aforemonetioned list
is actually a wish list. And in no way I expect Teneo-Hibernate to give me
all of this; but at least provide some launch pad.

Thanks again,
-Mdu
Re: [TENEO] Issues when loading models from an already existing Teneo database o [message #100490 is a reply to message #100478] Thu, 01 November 2007 10:50 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Mdu,
Teneo will do the ecore to db part for you. The only thing which can be tricky is that after
changing your model you have to update the database schema. You can do this through Teneo by
creating a new HbDataStore with the changed model. The db schema will then be updated. One thing to
note is that hibernate does not support all db update actions (mainly that new indexes are not added
to an existing table, but it will create new tables/columns when it notices that these are missing).
Also often updating the db schema can only be done if the database is locked (so no access to the db
for other users). I am not sure if this is an issue in your case.

For an ajax web editor for ecore there is an interesting link here:
http://wiki.eclipse.org/JFace_Data_Binding/GWT

See also several posts on the EMF newsgroup (search for posts with GWT in the subject).

I am myself working on a (ecore-)model-driven web form generator. But this is targeted at business
data oriented apps. This means that I do not intend to support all the flexibilities of an ecore
model (which are mainly reflected in featuremaps). So what I am doing will probably not support
editing the ecore model itself.

gr. Martin

Mdu Keswa wrote:
> Martin,
> Brilliant! This is a great start for me. Maybe I have missed a
> Teneo-Hibernate cookbook somewhere. Basically, ultimately I want to be
> able to support at least the following use cases with help of
> Teneo-Hibernate:
>
> 1. Start with annotized java interfaces to generate Ecore metamodel.
> 2. Store generated Ecore metamodel in a database (via Hibernate).
> 3. Load a metamodel from a database in 2. to generate objects to be
> stored in the database.
> 4. Using a web based(Ajax) Editor and via Eclipse Editor modify
> metamodel in 2.
> 4.1. Support for 'Entity Editor' so that end user with proper roles can
> add attributes and maybe relationships to an existing entity/metamodel
> 5. Support to develop a web based (Ajax) Form Builder driven by querying
> an existing Ecore metamodel from the database.
> 6. Support for Audit Trails whenever an object/entity (EObject) incurs
> C.R.U.D. (Create,Read,Update,Delete) events
>
> Maybe it's because Christmas is almost here but the aforemonetioned list
> is actually a wish list. And in no way I expect Teneo-Hibernate to give
> me all of this; but at least provide some launch pad.
>
> Thanks again,
> -Mdu
>


--

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: [TENEO] Issues when loading models from an already existing Teneo database or deleting them [message #609865 is a reply to message #98150] Mon, 01 October 2007 21:24 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Hugo,
1) this can occur if you have a type which has an id which you assign 'manually' (not generated by
the db). If two different instances of the same type have the same id then this error occurs.
2) Using an example, what I understand is that you store an EPackage P1 with an eClass C1 in the db
and then try to store an eobject which has this eclass c1 in the same db?
Did you pass P1 as an epackage to the hibernatedatastore (hbdatastore.setEPackages(...))?

gr. Martin

Hugo Bruneliere wrote:
> Hi,
>
> I'm using Teneo in order to provide a database-based implementation of
> the AM3 model repository generic interface (see
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.gmt/AM3 /plugins/org.eclipse.gmt.am3.core/src/org/eclipse/gmt/am3/co re/storage/?root=Technology_Project).
>
>
> I don't (or at least I don't seem to) have problems when adding,
> retrieving or deleting metamodels (i.e. EPackages) into/from the
> repository.
>
> However, I'm facing some issues when trying to do the same thing with
> terminal models conforming to loaded metamodels (i.e. EObjects which are
> instances of EClasses contained in previously loaded EPackages). For
> both issues, I have already checked that the models stored into the EMF
> resources are correct.
>
>
> 1) When calling
> " this.getHibernateDataStoreSession().delete(res.getContents() .get(0)); "
> with "res" the EMF resource storing the terminal model, the following
> exception is raised:
>
> org.eclipse.gmt.am3.core.storage.RepositoryException:
> org.hibernate.NonUniqueObjectException: a different object with the same
> identifier value was already associated with the session: [Deb#2]
> at
> org.eclipse.gmt.am3.repository.teneo.TeneoRepository.removeM odel(TeneoRepository.java:487)
>
> at
> org.eclipse.gmt.am3.repository.teneo.testrepository.main(tes trepository.java:178)
>
> Caused by: org.hibernate.NonUniqueObjectException: a different object
> with the same identifier value was already associated with the session:
> [Deb#2]
> at
> org.hibernate.engine.StatefulPersistenceContext.checkUniquen ess(StatefulPersistenceContext.java:556)
>
> at
> org.hibernate.event.def.DefaultDeleteEventListener.onDelete( DefaultDeleteEventListener.java:88)
>
> at
> org.hibernate.event.def.DefaultDeleteEventListener.onDelete( DefaultDeleteEventListener.java:49)
>
> at org.hibernate.impl.SessionImpl.fireDelete(SessionImpl.java:7 66)
> at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:744)
> at
> org.eclipse.emf.teneo.hibernate.HbSessionWrapper.delete(HbSe ssionWrapper.java:156)
>
>
> As a consequence, the EObjects composing the model are still stored into
> the database. Maybe this issue is one of the causes of the next problem
> but I'm not sure of that!
>
>
> 2) When working on a database which has been previously created (by
> another session) and trying to add a new terminal model (which conforms
> to an already stored metamodel), from
> " this.getHibernateDataStoreSession().saveOrUpdate(res.getCont ents().get(0)); "
> I got:
>
> org.eclipse.gmt.am3.core.storage.RepositoryException:
> java.lang.IllegalArgumentException: No annotated model element present
> for: Deb for type EClass has its epackage been registered with Teneo?
> at
> org.eclipse.gmt.am3.repository.teneo.TeneoRepository.addMode l(TeneoRepository.java:413)
>
> at
> org.eclipse.gmt.am3.repository.teneo.TeneoRepository.updateM odel(TeneoRepository.java:439)
>
> at
> org.eclipse.gmt.am3.repository.teneo.TeneoRepository.updateM odel(TeneoRepository.java:464)
>
> at
> org.eclipse.gmt.am3.repository.teneo.testrepository.main(tes trepository.java:127)
>
> Caused by: java.lang.IllegalArgumentException: No annotated model
> element present for: Deb for type EClass has its epackage been
> registered with Teneo?
> at
> org.eclipse.emf.teneo.annotations.pamodel.impl.PAnnotatedMod elImpl.checkAnnotatedPresent(PAnnotatedModelImpl.java:337)
>
> at
> org.eclipse.emf.teneo.annotations.pamodel.impl.PAnnotatedMod elImpl.getPAnnotated(PAnnotatedModelImpl.java:279)
>
> at
> org.eclipse.emf.teneo.mapping.strategy.impl.EntityResolvingN ameStrategy.toEntityName(EntityResolvingNameStrategy.java:84 )
>
> at
> org.eclipse.emf.teneo.hibernate.EMFInterceptor.getEntityName (EMFInterceptor.java:75)
>
> at
> org.hibernate.impl.SessionImpl.guessEntityName(SessionImpl.j ava:1765)
> at
> org.hibernate.impl.SessionImpl.getEntityPersister(SessionImp l.java:1338)
> at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.jav a:180)
> at
> org.hibernate.event.def.AbstractSaveEventListener.getEntityS tate(AbstractSaveEventListener.java:487)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:84)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>
> at
> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:507)
> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :499)
> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :495)
> at
> org.eclipse.emf.teneo.hibernate.HbSessionWrapper.saveOrUpdat e(HbSessionWrapper.java:151)
>
>
> What is strange is that I'm succeeding in retrieving the corresponding
> metamodel (i.e. EPackages)...
>
>
> Does anybody have ideas about where do these problems come from and how
> to solve them?
>
> Best regards,
>
> Hugo
>


--

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: [TENEO] Issues when loading models from an already existing Teneo database or deleting them [message #609873 is a reply to message #98211] Tue, 02 October 2007 15:07 Go to previous message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
Registered: July 2009
Senior Member
Hi Martin,

Thanks for your answers, they helped me finding where my problems came
from ;-)

Best regards,

Hugo

Martin Taal a écrit :
> Hi Hugo,
> 1) this can occur if you have a type which has an id which you assign
> 'manually' (not generated by the db). If two different instances of the
> same type have the same id then this error occurs.
> 2) Using an example, what I understand is that you store an EPackage P1
> with an eClass C1 in the db and then try to store an eobject which has
> this eclass c1 in the same db?
> Did you pass P1 as an epackage to the hibernatedatastore
> (hbdatastore.setEPackages(...))?
>
> gr. Martin
>
> Hugo Bruneliere wrote:
>> Hi,
>>
>> I'm using Teneo in order to provide a database-based implementation of
>> the AM3 model repository generic interface (see
>> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.gmt/AM3 /plugins/org.eclipse.gmt.am3.core/src/org/eclipse/gmt/am3/co re/storage/?root=Technology_Project).
>>
>>
>> I don't (or at least I don't seem to) have problems when adding,
>> retrieving or deleting metamodels (i.e. EPackages) into/from the
>> repository.
>>
>> However, I'm facing some issues when trying to do the same thing with
>> terminal models conforming to loaded metamodels (i.e. EObjects which
>> are instances of EClasses contained in previously loaded EPackages).
>> For both issues, I have already checked that the models stored into
>> the EMF resources are correct.
>>
>>
>> 1) When calling
>> " this.getHibernateDataStoreSession().delete(res.getContents() .get(0)); "
>> with "res" the EMF resource storing the terminal model, the following
>> exception is raised:
>>
>> org.eclipse.gmt.am3.core.storage.RepositoryException:
>> org.hibernate.NonUniqueObjectException: a different object with the
>> same identifier value was already associated with the session: [Deb#2]
>> at
>> org.eclipse.gmt.am3.repository.teneo.TeneoRepository.removeM odel(TeneoRepository.java:487)
>>
>> at
>> org.eclipse.gmt.am3.repository.teneo.testrepository.main(tes trepository.java:178)
>>
>> Caused by: org.hibernate.NonUniqueObjectException: a different object
>> with the same identifier value was already associated with the
>> session: [Deb#2]
>> at
>> org.hibernate.engine.StatefulPersistenceContext.checkUniquen ess(StatefulPersistenceContext.java:556)
>>
>> at
>> org.hibernate.event.def.DefaultDeleteEventListener.onDelete( DefaultDeleteEventListener.java:88)
>>
>> at
>> org.hibernate.event.def.DefaultDeleteEventListener.onDelete( DefaultDeleteEventListener.java:49)
>>
>> at org.hibernate.impl.SessionImpl.fireDelete(SessionImpl.java:7 66)
>> at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:744)
>> at
>> org.eclipse.emf.teneo.hibernate.HbSessionWrapper.delete(HbSe ssionWrapper.java:156)
>>
>>
>> As a consequence, the EObjects composing the model are still stored
>> into the database. Maybe this issue is one of the causes of the next
>> problem but I'm not sure of that!
>>
>>
>> 2) When working on a database which has been previously created (by
>> another session) and trying to add a new terminal model (which
>> conforms to an already stored metamodel), from
>> " this.getHibernateDataStoreSession().saveOrUpdate(res.getCont ents().get(0)); "
>> I got:
>>
>> org.eclipse.gmt.am3.core.storage.RepositoryException:
>> java.lang.IllegalArgumentException: No annotated model element present
>> for: Deb for type EClass has its epackage been registered with Teneo?
>> at
>> org.eclipse.gmt.am3.repository.teneo.TeneoRepository.addMode l(TeneoRepository.java:413)
>>
>> at
>> org.eclipse.gmt.am3.repository.teneo.TeneoRepository.updateM odel(TeneoRepository.java:439)
>>
>> at
>> org.eclipse.gmt.am3.repository.teneo.TeneoRepository.updateM odel(TeneoRepository.java:464)
>>
>> at
>> org.eclipse.gmt.am3.repository.teneo.testrepository.main(tes trepository.java:127)
>>
>> Caused by: java.lang.IllegalArgumentException: No annotated model
>> element present for: Deb for type EClass has its epackage been
>> registered with Teneo?
>> at
>> org.eclipse.emf.teneo.annotations.pamodel.impl.PAnnotatedMod elImpl.checkAnnotatedPresent(PAnnotatedModelImpl.java:337)
>>
>> at
>> org.eclipse.emf.teneo.annotations.pamodel.impl.PAnnotatedMod elImpl.getPAnnotated(PAnnotatedModelImpl.java:279)
>>
>> at
>> org.eclipse.emf.teneo.mapping.strategy.impl.EntityResolvingN ameStrategy.toEntityName(EntityResolvingNameStrategy.java:84 )
>>
>> at
>> org.eclipse.emf.teneo.hibernate.EMFInterceptor.getEntityName (EMFInterceptor.java:75)
>>
>> at
>> org.hibernate.impl.SessionImpl.guessEntityName(SessionImpl.j ava:1765)
>> at
>> org.hibernate.impl.SessionImpl.getEntityPersister(SessionImp l.java:1338)
>> at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.jav a:180)
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.getEntityS tate(AbstractSaveEventListener.java:487)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:84)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>>
>> at
>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:507)
>> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :499)
>> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :495)
>> at
>> org.eclipse.emf.teneo.hibernate.HbSessionWrapper.saveOrUpdat e(HbSessionWrapper.java:151)
>>
>>
>> What is strange is that I'm succeeding in retrieving the corresponding
>> metamodel (i.e. EPackages)...
>>
>>
>> Does anybody have ideas about where do these problems come from and
>> how to solve them?
>>
>> Best regards,
>>
>> Hugo
>>
>
>


--
--------------------------------------------------------
Hugo Bruneliere - R&D Engineer
ATLAS Group (INRIA & LINA) - University of Nantes
2, rue de la Houssiniere
44322 Nantes Cedex 3 - France
office +33 2 51 12 58 10 /\ cell.+33 6 07 42 45 30
EMail: Hugo.Bruneliere@univ-nantes.fr
http://www.sciences.univ-nantes.fr/lina/atl/
--------------------------------------------------------


--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
Re: [TENEO] Issues when loading models from an already existing Teneo database o [message #610185 is a reply to message #98150] Wed, 31 October 2007 18:04 Go to previous message
Eclipse UserFriend
Originally posted by: mduduzi.keswa.isizwe.com

Hi,
I have been trying to figure out a way to store ecore metamodel in a
database instead of the file based approach. I'm currently prototyping
using storing EObjects into a database using Teneo-Hibernate interface.
Will this (mentioned in this post) plugin/tool allow me to do such? Is
this part of Teneo-Hibernate interface. I'd appreciate it if I can be
pointed to an example or a detailed explanation on how to go about doing
this - at least to get started.

Thanks,
-Mdu
Re: [TENEO] Issues when loading models from an already existing Teneo database o [message #610186 is a reply to message #100452] Wed, 31 October 2007 18:24 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Mdu,
If you mean Teneo as the tool/plugin then Teneo should get pretty far in persisting ecore models
itself. I have only tried it for demo purposes and small testcases.

Here is part of a test case I have used to re-produce an issue someone had persisting ecore models.
I copied and pasted it and reformatted is it may not be syntactically correct but you get the meaning:

HbDataStore hbds = HbHelper.INSTANCE.createRegisterDataStore("test");
final Properties props = new Properties();

// here set your hibernate properties (jdbc url, etc.)
// hbds.setHibernateProperties(props);

// here set your teneo properties for example:
// props.setProperty(PersistenceOptions.INHERITANCE_MAPPING, "JOINED");
// props.put(PersistenceOptions.JOIN_TABLE_NAMING_STRATEGY, "ejb3");
// props.put(PersistenceOptions.JOIN_TABLE_FOR_NON_CONTAINED_AS SOCIATIONS, "true");
// hbds.setPersistenceProperties(props);

// sets the epackages stored in this datastore
hbds.setEPackages(new EPackage[] { EcorePackage.eINSTANCE, XMLTypePackage.eINSTANCE });

// create the db/tables
hbds.initialize();

// now store some epackages
Session s = hbds.getSessionFactory().openSession();
s.beginTransaction();

// the epacks list contains the EPackages you want to persist
for (EPackage epack : epacks) {
s.save(epack);
}
s.getTransaction().commit();

// now for test purposes read them back and put them in an array
s = hbds.getSessionFactory().openSession();
final List l = s.createQuery("select e from ecore.EPackage e").list();
final EPackage[] newEpacks = new EPackage[l.size()];
int i = 0;
for (Object o : l) {
final EPackage epack = (EPackage) o;
newEpacks[i++] = epack;
}

gr. Martin

Mdu Keswa wrote:
> Hi,
> I have been trying to figure out a way to store ecore metamodel in a
> database instead of the file based approach. I'm currently prototyping
> using storing EObjects into a database using Teneo-Hibernate interface.
> Will this (mentioned in this post) plugin/tool allow me to do such? Is
> this part of Teneo-Hibernate interface. I'd appreciate it if I can be
> pointed to an example or a detailed explanation on how to go about doing
> this - at least to get started.
>
> Thanks,
> -Mdu
>


--

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: [TENEO] Issues when loading models from an already existing Teneo database o [message #610188 is a reply to message #100465] Thu, 01 November 2007 10:22 Go to previous message
Eclipse UserFriend
Originally posted by: mduduzi.keswa.isizwe.com

Martin,
Brilliant! This is a great start for me. Maybe I have missed a
Teneo-Hibernate cookbook somewhere. Basically, ultimately I want to be
able to support at least the following use cases with help of
Teneo-Hibernate:

1. Start with annotized java interfaces to generate Ecore metamodel.
2. Store generated Ecore metamodel in a database (via Hibernate).
3. Load a metamodel from a database in 2. to generate objects to be stored
in the database.
4. Using a web based(Ajax) Editor and via Eclipse Editor modify metamodel
in 2.
4.1. Support for 'Entity Editor' so that end user with proper roles can
add attributes and maybe relationships to an existing entity/metamodel
5. Support to develop a web based (Ajax) Form Builder driven by querying
an existing Ecore metamodel from the database.
6. Support for Audit Trails whenever an object/entity (EObject) incurs
C.R.U.D. (Create,Read,Update,Delete) events

Maybe it's because Christmas is almost here but the aforemonetioned list
is actually a wish list. And in no way I expect Teneo-Hibernate to give me
all of this; but at least provide some launch pad.

Thanks again,
-Mdu
Re: [TENEO] Issues when loading models from an already existing Teneo database o [message #610190 is a reply to message #100478] Thu, 01 November 2007 10:50 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Mdu,
Teneo will do the ecore to db part for you. The only thing which can be tricky is that after
changing your model you have to update the database schema. You can do this through Teneo by
creating a new HbDataStore with the changed model. The db schema will then be updated. One thing to
note is that hibernate does not support all db update actions (mainly that new indexes are not added
to an existing table, but it will create new tables/columns when it notices that these are missing).
Also often updating the db schema can only be done if the database is locked (so no access to the db
for other users). I am not sure if this is an issue in your case.

For an ajax web editor for ecore there is an interesting link here:
http://wiki.eclipse.org/JFace_Data_Binding/GWT

See also several posts on the EMF newsgroup (search for posts with GWT in the subject).

I am myself working on a (ecore-)model-driven web form generator. But this is targeted at business
data oriented apps. This means that I do not intend to support all the flexibilities of an ecore
model (which are mainly reflected in featuremaps). So what I am doing will probably not support
editing the ecore model itself.

gr. Martin

Mdu Keswa wrote:
> Martin,
> Brilliant! This is a great start for me. Maybe I have missed a
> Teneo-Hibernate cookbook somewhere. Basically, ultimately I want to be
> able to support at least the following use cases with help of
> Teneo-Hibernate:
>
> 1. Start with annotized java interfaces to generate Ecore metamodel.
> 2. Store generated Ecore metamodel in a database (via Hibernate).
> 3. Load a metamodel from a database in 2. to generate objects to be
> stored in the database.
> 4. Using a web based(Ajax) Editor and via Eclipse Editor modify
> metamodel in 2.
> 4.1. Support for 'Entity Editor' so that end user with proper roles can
> add attributes and maybe relationships to an existing entity/metamodel
> 5. Support to develop a web based (Ajax) Form Builder driven by querying
> an existing Ecore metamodel from the database.
> 6. Support for Audit Trails whenever an object/entity (EObject) incurs
> C.R.U.D. (Create,Read,Update,Delete) events
>
> Maybe it's because Christmas is almost here but the aforemonetioned list
> is actually a wish list. And in no way I expect Teneo-Hibernate to give
> me all of this; but at least provide some launch pad.
>
> Thanks again,
> -Mdu
>


--

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
Previous Topic:[Teneo]foreign key element in jdo not generated properly?
Next Topic:[CDO] New Model Migrator Utility
Goto Forum:
  


Current Time: Sat Jul 27 12:38:39 GMT 2024

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

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

Back to the top