• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

OpenJPA

 
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

Is there a good tutorial for getting started on OpenJPA? From what I have been looking till now, I found tutorials on EclipseLink, TopLink etc JPA implementations but not on OpenJPA. Please, if anybody knows a good tutorial please post it here.

Thanks
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why should it differ that much? JPA is a standard specification. All of the implementations ought to behave the same. Just get the implementation's JAR file(s), place them in the classpath and do your JPA thing according to a standard JPA tutorial.

Sun at least has one: http://java.sun.com/javaee/5/docs/tutorial/doc/bnbpz.html
 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bauke Scholtz wrote:Why should it differ that much? JPA is a standard specification. All of the implementations ought to behave the same. Just get the implementation's JAR file(s), place them in the classpath and do your JPA thing according to a standard JPA tutorial.

Sun at least has one: http://java.sun.com/javaee/5/docs/tutorial/doc/bnbpz.html



Thanks for replying Bauke. I am starting on implementing one of the JPA implementations and I will take it from there.
 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, This tutorial works fine for both JPA and OpenJPA. I just checked. To Use OpenJPA, just select it as the Persistence provider while adding the JPA capabilities.


http://www.myeclipseide.com/documentation/quickstarts/jpa/

One small problem though. Using OpenJPA the update operation's giving the exact results as using JPA with one additional line.

This is the result I am getting using each of them:


OpenJPA Result:
--------------

Apr 5, 2009 9:47:43 PM com.aa.OpenJPA.EntityManagerHelper log
INFO: finding Productline instance with id: Men's Shoes
94 SampleOpenJPAProjectPU INFO [main] openjpa.Runtime - Starting OpenJPA 1.2.0
203 SampleOpenJPAProjectPU INFO [main] openjpa.jdbc.JDBC - Using dictionary class "org.apache.openjpa.jdbc.sql.DerbyDictionary".
547 SampleOpenJPAProjectPU INFO [main] openjpa.Enhance - Creating subclass for "[class com.aa.OpenJPA.Productline]". This means that your application will be less efficient and will consume more memory than it would if you ran the OpenJPA enhancer. Additionally, lazy loading will not be available for one-to-one and many-to-one persistent attributes in types using field access; they will be loaded eagerly instead.
*REVISED* Product Line [productLine=Men's Shoes, textDescription=Shoes for men., image=null, html description=<strong>Men's Shoes</strong>]



JPA Result:
----------

Apr 5, 2009 9:45:20 PM com.aa.jpa.EntityManagerHelper log
INFO: finding Productline instance with id: Men's Shoes
[TopLink Info]: 2009.04.05 09:45:21.171--ServerSession(7578443)--TopLink, version: Oracle TopLink Essentials - 2.0 (Build b40-rc (03/21/2007))
[TopLink Info]: 2009.04.05 09:45:21.421--ServerSession(7578443)--file:/D:/JPA%20Eclipse/JPA%20MyEclipse%20Workspace/SampleJPAProject/bin/-SampleJPAProjectPU login successful
*REVISED* Product Line [productLine=Men's Shoes, textDescription=Shoes for men., image=null, html description=<strong>Men's Shoes</strong>]



I have bolded the line which is different. I have read previously that we have to use some kind of enhancer while using OpenJPA. Is this caused because of that?

Note: Yes, the error's caused because of that. Detailed information is here. http://openjpa.apache.org/builds/1.0.0/apache-openjpa-1.0.0/docs/manual/ref_guide_pc_enhance.html

Thanks.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Arjun -
The message Creating subclass for... is because by default MyEclipse doesn't run the OpenJPA enhancer. Enhancing your Entity classes is very important when using OpenJPA. I wrote a blog posting that talks about OpenJPA enhancement here and another about using an Eclipse builder to enhance when running inside (My)Eclipse.

Hopefully this helps!

-Rick

Arjun Reddy wrote:Ok, This tutorial works fine for both JPA and OpenJPA. I just checked. To Use OpenJPA, just select it as the Persistence provider while adding the JPA capabilities.


http://www.myeclipseide.com/documentation/quickstarts/jpa/

One small problem though. Using OpenJPA the update operation's giving the exact results as using JPA with one additional line.

This is the result I am getting using each of them:

.....
547 SampleOpenJPAProjectPU INFO [main] openjpa.Enhance - Creating subclass for "[class com.aa.OpenJPA.Productline]". This means that your application will be less efficient and will consume more memory than it would if you ran the OpenJPA enhancer. Additionally, lazy loading will not be available for one-to-one and many-to-one persistent attributes in types using field access; they will be loaded eagerly instead.
*REVISED* Product Line [productLine=Men's Shoes, textDescription=Shoes for men., image=null, html description=<strong>Men's Shoes</strong>]

 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rick Curtis wrote:Arjun -
The message Creating subclass for... is because by default MyEclipse doesn't run the OpenJPA enhancer. Enhancing your classes is very important when using OpenJPA. I wrote a blog posting that talks about OpenJPA enhancement here and another about using an Eclipse builder to enhance when running inside Eclipse.

Hopefully this helps!

-Rick

Arjun Reddy wrote:Ok, This tutorial works fine for both JPA and OpenJPA. I just checked. To Use OpenJPA, just select it as the Persistence provider while adding the JPA capabilities.


http://www.myeclipseide.com/documentation/quickstarts/jpa/

One small problem though. Using OpenJPA the update operation's giving the exact results as using JPA with one additional line.

This is the result I am getting using each of them:

.....
547 SampleOpenJPAProjectPU INFO [main] openjpa.Enhance - Creating subclass for "[class com.aa.OpenJPA.Productline]". This means that your application will be less efficient and will consume more memory than it would if you ran the OpenJPA enhancer. Additionally, lazy loading will not be available for one-to-one and many-to-one persistent attributes in types using field access; they will be loaded eagerly instead.
*REVISED* Product Line [productLine=Men's Shoes, textDescription=Shoes for men., image=null, html description=<strong>Men's Shoes</strong>]



Thanks for the reply Rick. I will check it out.

-Arjun
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic