Using Hibernate as JPA Provider for GlassFish V3

GlassFish V3 prelude ships with EclipseLink as the default JPA provider. The question that frequently gets asked is: How hard it is to to use Hibernate as the persistence provider with Glassfish V3. The answer is:  Not at all :). It is even simpler to achieve this than it was with V2. Thanks to the wonderful V3 update center it is as easy as 1-2-3. Lets  walk through the steps:

1. Download and install GlassFish V3 prelude with update tool.

2.  Launch the update tool. Hibernate is available under "Available Add-ons" as can be seen below. Check "Hibernate JPA" and click install.


3. GlassFish will be ready to use Hibernate as JPA provider[1]. The file <installdir>/hibernate/overview.txt contains all the information to get you started.

[1] Please note that we had used Derby 10.4.2.1 (also available with the update tool) for testing.


Comments:

I need to use Hibernate 3.6 but the hibernate jpa addon on gf3 comes with 3.5, is there a way by wich i can use 3.6?

I tried not installing this addon, and adding hibernate 3.6 jars to my project but gf shows an error when deploying.

Posted by Alejandra on November 03, 2010 at 02:16 AM PDT #

How are you bundling hibernate 3.6 with your app? What error do you get with 3.6?

Posted by Mitesh Meswani on November 03, 2010 at 08:56 AM PDT #

I'm doing a similar thing and putting all the Hibernate 3.6 jars in the domain/lib dir, however I end up with classloader problems when my app has bundled 3rd party jars that are also needed by Hibernate.

An example of this is stringtemplate which has a dependency on altlr and won't work unless I put the stringtemplate jar also in the domain/lib directory. I'd rather it was bundled with my app so it can be managed by my build tool rather than having to manually place it in the domain/lib.
Any suggestions?

Posted by Phill on March 31, 2011 at 03:35 AM PDT #

Even with the update tool I still cannot seem to have non-jta transactions. Meaning I am using Hibernate add on, and I am using persistence provider as well as <provider>org.hibernate.ejb.HibernatePersistence</provider>.... Not sure what to do.... SEVERE: Exception while preparing the app : The persistence-context-ref-name [.../em] in module [....] resolves to a persistence unit called [blPU] which is of type RESOURCE_LOCAL. Only persistence units with transaction type JTA can be used as a container managed entity manager. Please verify your application.

Posted by programmer on May 23, 2011 at 02:05 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Mitesh Meswani

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
Bookmarks