• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPA Layer for Java EE and SE environments

 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

How can I define one Persistence layer using JPA that works for both Java SE and EE environments? Is there any way to acheive this?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand the question. Why would it not work in one or other environment?
 
Benjamin Winterberg
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out http://www.hibernate.org/328.html how to implement generic data access objects. You can perfectly use this approach in JSE and JEE applications.
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Sturrock wrote:I don't understand the question. Why would it not work in one or other environment?


When I say for example, in my Session bean class,


@PersistenceContext
EntityManager em;


Who is responsible for injecting the dependency? It is the App server or rather the Persistence Provider. I would like to take that dependency out of the APP Server and define a Persistence layer using JPA that can run on both the App Server and as a standalone service. I guess the option for me would be to use Hibernate as the EntityManager service. Am I right?
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any ideas?
 
Benjamin Winterberg
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should take a look at spring framework. Springs dependancy injection doesnt depend on a jee container. It works the same in JEE and JSE environments. And JPA integration of spring is very good.
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was just considering this. Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic