Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Enable Full Use API of EntityManager(How to use the full API of the javax.persistence.EntityManager with Eclipse Teneo and an EMF model?)
[Teneo] Enable Full Use API of EntityManager [message #1720800] Thu, 21 January 2016 07:28 Go to next message
Timo Rohrberg is currently offline Timo RohrbergFriend
Messages: 69
Registered: September 2011
Location: Karlsruhe
Member
https://www.eclipse.org/forums/index.php/t/1074028/ seems to fit better here.

Hello everybody
(or should I say Martin Taal Smile),

we try to use Eclipse Teneo to persist our business models created with Eclipse EMF into a PostgreSQL database and read it from there using the standard JPA EntityMananger API. Unfortunately, the mapping automatically created by Eclipse Teneo does not allow us to use EntityManager.find() method for example as it does not find a valid mapping of our EMF entities.

We created a simple example project attached to this post which can be imported into a default Eclipse Luna Modeling installation/workspace. One just needs to install Eclipse Teneo + Dependencies from [1] and [2], and place the h2 database driver (contained in the attached ZIP) into the dropins folder of eclipse.

We also found an older post [3] which ecountered the similar problem than we do and obviously solved it - just that the solution described there does not work for us.

Do you guys have any idea what is wrong with the setup? In our opinion it can only related to the way we model our entities and/or some Teneo/Hibernate configuration which we are not aware of.

We're glad for any hints not matter if they contain a final solution.

Thanks a lot.

Regards
Timo

[1] http://www.elver.org/eclipse/2.1.0/update
[2] http://download.eclipse.org/modeling/emf/teneo/updates/2.1.0/interim/
[3] https://www.eclipse.org/forums/index.php/t/199012/
Re: [Teneo] Enable Full Use API of EntityManager [message #1721794 is a reply to message #1720800] Sat, 30 January 2016 21:55 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Timo,
Thanks for the test project, was great. I spend some time on this one, but my conclusion is the same. Teneo uses the hbm mapping approach. When calling the find method, hibernate uses the full class name as the entity name and can't find the entity as Teneo maps using the shorter EClass name.

There is a workaround:
https://wiki.eclipse.org/Teneo/Hibernate/FAQ#Unknown_Entity

But I think it is better to use the standard mapping approach and implement the non-working methods in a different way as you do in the test project. Afaics these are not big workarounds and would work just as well.

But let me know what you think.

gr. Martin




Re: [Teneo] Enable Full Use API of EntityManager [message #1722173 is a reply to message #1721794] Wed, 03 February 2016 08:54 Go to previous messageGo to next message
Timo Rohrberg is currently offline Timo RohrbergFriend
Messages: 69
Registered: September 2011
Location: Karlsruhe
Member
Hello Martin,

thank you a lot for your reply. I tried the workaround with the test project (which you probably also did already) and it works. My collegues are now trying to refactor our PersistenceService implementation. Up to now, it was using JPQL statements and not the EntityManager.find() method since that was not working.

To my recent knowledge of Hibernate, the problem of using JPQL statements over the EntityManager API methods is that caching would not work. Every JPQL statement is executed directly towards the database circumventing the cache. And that is of course a performance problem.

Or is Teneo working in a different way with a Cache if that is enabled (e.g. ehcache)?

So currently, the only possibility I see is to use that "workaround" to use the EntityManager.find() method where possible and to adjust the JPQL statements in the other DAO methods to use the fully qualified interface name instead of the short name.

Let me know what you think about the caching etc...

Best regards
Timo
Re: [Teneo] Enable Full Use API of EntityManager [message #1722673 is a reply to message #1720800] Mon, 08 February 2016 08:35 Go to previous messageGo to next message
ctinformatics services is currently offline ctinformatics servicesFriend
Messages: 1
Registered: February 2016
Junior Member
The JPA 2.0 perfect Hibernate EntityManager is based on top of the center of Hibernate and Hibernate Annotations. Beginning from form 3.5, we have packaged in a solitary Hibernate dissemination all the fundamental modules:

Sleep Core: the local Hibernate APIs and center motor

Sleep Annotations: the comment based mapping

Sleep EntityManager: the JPA 2.0 APIs and livecycle semantic execution

Download the Hibernate Core dispersion. Set up your classpath (after you have made another venture in your most loved IDE):
Re: [Teneo] Enable Full Use API of EntityManager [message #1722858 is a reply to message #1722173] Tue, 09 February 2016 17:28 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Timo,
Another thought, you can get to the underlying Hibernate session object and try get/load on the session

final Session session = (Session) getEntityManager().getDelegate();
and then you can try session.get or session.load.

See here for the difference:
http://stackoverflow.com/questions/608947/hibernate-difference-between-session-get-and-session-load

This worked for me if I used the get/load which expects a String (entityname) parameter.

gr. Martin
Previous Topic:[EEF] Trouble customizing widget generation
Next Topic:[EMF Forms] Custom control get parent of an eStructuralFeature
Goto Forum:
  


Current Time: Fri Apr 19 20:20:58 GMT 2024

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

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

Back to the top