• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPA with Java SE Environment

 
Scott Updike
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is anyone familiar with utilizing the JPA within the Java SE environment? Any good books that anyone would recommend??

I have a standard Struts-based application (on Glassfish V2) within JSE and would like to investigate transitioning from coding JDBC to leveraging the JPA. Not sure how to do it within JSE (all the books I see are inreference to the JEE environment).

Also, if I go with using JPA, do I have to use a framework such as Hibernate or can I code JPA directly? Is Hibernate really worth its weight?

Thanks in advance,
Scott Updike
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, one of the great things about Hibernate is that once you've got it set up, you can connect from SE just as easily as EE.

All you need to do is put the Hibernate related jar files into a location that can be found by the compiler & runtime environment, make sure you have the appropriate JDBC drivers download, a properly configured hibernate.cfg.xml file, and you can run and compile your code with nothing more than the JDK. It also makes testing your code with JUnit very easy as well.

Here's a little tutorial I put together that sets up a Hibernate environment on Windows XP with MySQL, and tests that environment using nothing more than the JDK and the javac compiler.

Configuring and Testing a Hibernate Environment with only the JDK

I also have a recently released Hibernate book that contains many SDK examples. Feel free to message me through the JavaRanch if you'd like to know more about it.

Kindest regards,

-Cameron McKenzie
[ May 07, 2008: Message edited by: Cameron Wallace McKenzie ]
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using JPA in JSE is very similar to using it in JEE, the main difference being transactions (local vs JTA).

Some info on this here:
http://en.wikibooks.org/wiki/Java_Persistence/Runtime#Java_Standard_Edition

There are several good JPA books, Pro EJB 3 is one,
http://www.amazon.com/gp/product/1590596455/102-2412923-9620152?v=glance&n=283155

JPA is just a spec, so you need a provider. This could be Hibernate, EclipseLink, TopLink, OpenJPA, or one of many other providers. The benefit of using JPA is that you have choice in your provider and do not get locked into a single product's proprietary API.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic