• 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

where JPA code should go?

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please have a look at following code:



It's from https://glassfish.dev.java.net/javaee5/persistence/persistence-example.html. It's kind of testing code for JPA.

Where should I write this code in my project???

Should I write this in stateless session bean (as if I was performing database operations in stateless session bean before using JPA) or in POJO???

Or somewhere else???

Thanks.
[ December 04, 2007: Message edited by: ankur rathi ]
 
Ranch Hand
Posts: 662
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well you can write it inside your stateless session bean. But, it depends on what other responsibilities you have given your session bean.
Does it do just the job of setting up the entity manager and calling the business methods and finshing off the work? or it has more responsibilities. Also depends on how many entity managers you use.

I suggest having a separate layer which does this and return after the job is done. Moreover, even if you want to replace the entire entity manager stuff and mange your objects(POJOS) all by yourself you can just replace it separately without any change in the session code (Mind you this is the client interface to the app running inside your server).

Also what made you ask the question that this should be written inside your POJO?
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Arun Kumarr:
Well you can write it inside your stateless session bean. But, it depends on what other responsibilities you have given your session bean.
Does it do just the job of setting up the entity manager and calling the business methods and finshing off the work? or it has more responsibilities. Also depends on how many entity managers you use.



It does just that - creating EntityManagerFactory, EntityManager object and calling business methods. Not sure about the number of entity managers I will be required.


I suggest having a separate layer which does this and return after the job is done. Moreover, even if you want to replace the entire entity manager stuff and mange your objects(POJOS) all by yourself you can just replace it separately without any change in the session code (Mind you this is the client interface to the app running inside your server).



Okay. So what kind of layer it cab be??? Can't that code go in POJO and I call it from stateless session bean.


Also what made you ask the question that this should be written inside your POJO?



Actually I should have been more specific. I meant, the code should go in any of the implementation of DAO. And creating 'DAO Factory object' and 'DAO object' code can go in stateless session bean. Does this make sense?

Thanks a ton.
 
After some pecan pie, you might want to cleanse your palatte with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic