• 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

Technology related question

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,

We are to design a Persistence layer as part of the development process. I would like to know which combination from the below that would be ideal for the requirement as stated below,

Technology combinations :

(1) Spring + Hibernate
(2) Spring + JPA

Requirements:
(1) Application should be easily portable across different app servers
(2) Application should be scalable
(3) Application should easily integrate with any new orm tool that might be used in the future

What is your suggestion guys?
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,

Now if I have a Persistence layer that has thee different technologies to access the database (like Hibernate, JDBC, iBatis) could I build a wrapper around this by using Spring that controls all three technologes for databse access? For example, can I do something like this,


If the above would be possible, then how would I control my transactions?
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any suggestions guys!
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JPA is a standard, Hibernate is an ORM (that includes an implementation of that standard). So if you want ot follow the usual advice, code to the standard.

Other than that this is a Spring question so I'll move it to a more appropriate forum.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As for the second question, it is possible, you can use a mix of technologies in your persistence layer. To control transactions, mark classes or methods in your service layer with the '@Transactional' annotation and add '<tx:annotation-driven>' to your spring application context configuration. Spring will start a transaction at the beginning of the method call, the transaction will be live as the service layer class makes calls to your persistence layer, and the transaction will end when the method in the service layer class ends. For more information check out the chapter on transaction management in the Spring documentation.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Nathan! The transaction would be managed by the EJB Session bean which forms the service layer of my application. Would this fit in the kind of Persistence layer that I'm trying to build? I mean the transaction propogation and so on...
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I checked out the docs from Spring and of course some browsing and found that I can user Spring + JPA (with HibernateJpaVendorAdapter) as the JpaVendorAdapter.

Now the Question that pops up my mind is that what would be the difference when I wire a LocalSessionFactoryBean or a LocalContainerEntityManagerFactoryBean to my Persistence layer. What is the difference between the two and of course with the latter (LocalContainerEntityManagerFactoryBean), I'm using Hibernate as my JPA implementation. Where is the difference? I know that JPA is a standard but apart from that what is the major advantage of the latter approach (with LocalContainerEntityManagerFactoryBean)?

Ideas really appreciated!
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
LocalContainerEntityManagerFactoryBean is used with JPA and LocalSessionFactoryBean is used if you're using Hibernate directly. The main advantage (in addition to JPA being a standard) is that JPA requires less configuration - it's mostly just annotations on your beans.

As for using a EJB Session bean as the service layer - I haven't done this before, but I found a IBM DeveloperWorks tutorial/article about it.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic