File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Technology related question

 
Joe Harry
Ranch Hand
Posts: 10045
3
Eclipse IDE Mac PPC Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • 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 Harry
Ranch Hand
Posts: 10045
3
Eclipse IDE Mac PPC Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • 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 Harry
Ranch Hand
Posts: 10045
3
Eclipse IDE Mac PPC Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any suggestions guys!
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • 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 Harry
Ranch Hand
Posts: 10045
3
Eclipse IDE Mac PPC Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • 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 Harry
Ranch Hand
Posts: 10045
3
Eclipse IDE Mac PPC Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • 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 Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic