File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Changing Session to EntityManager (hiberante) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Changing Session to EntityManager (hiberante)" Watch "Changing Session to EntityManager (hiberante)" New topic

Changing Session to EntityManager (hiberante)

Inocencio Oliveira

Joined: Oct 13, 2005
Posts: 23
I was changing the connection context from my application. I�m trying to get EntityManager pattern up.

I created a persistence.xml and defined some tags:

Hence, my database is a H2 link here. I chose this to run my app into a local context, because the other database must be SQL Server, and I need to work with both.

In hibernate session context, My connect was running ok, creating automatic DDL, inserting, retrieving datas, deleting, everything was ok, but now I am trying to use EntityManager pattern with JPA and some stuffs are getting wrong like that:

:arrow: It�s doesn�t knows any H2 dialect. Appears some warning information:

And the hibernate try to create the tables but something get wrong when it�s try to create sequence

I was defined sequence schema into my persistence class like:

So, hibernate show an error message:

I really don�t know how to fix it. In the session context everything was ok, but now everything get wrong. I have to fix it and put H2 to work with toplink JPA EntityManager context.

Someone have done H2 running with this context?

Thanks all!
[ December 28, 2007: Message edited by: Inocencio Oliveira ]

<b>Keep your mind flowing away!</b>
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Well the main thing I see, is that you have both Toplink and Hibernate in your persistence.xml. Which one are you actually using?


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

OK, so based on your errors (both are coming from Toplink) you are using Toplink, so remove the Hibernate property and use a Toplink property for the dialect.

Mike Keith
Ranch Hand

Joined: Jul 14, 2005
Posts: 304
The error message is just TopLink Essentials telling you to set the database platform using the toplink "" property. So, to use SQL Server you would specify the SQL Server platform class:


Pro JPA 2: Mastering the Java Persistence API
I agree. Here's the link:
subject: Changing Session to EntityManager (hiberante)
It's not a secret anymore!