Performance point of view, which one should be the better option whether Spring JPA Hibernate or Spring Hibernate ?
I do not expect any relevant Perfomance Difference between Hibernate JPA and classic Hibernate.
I don't think you should worry about it. Reasonably it is as Ralph expressed it. Instead go ahead and use JPA because your code will be vendor independent. Or go for Hibernate if you have a reason for it, (maybe better documented or something).
Hope this link helps for performance report you are looking at
http://www.jpab.org/All/All/All.html.
Related
I am new to Spring and Hibernate. I have a project using Spring, Hibernate and PostgreSQL. I know that I can query the database using Spring Data JPA or Hibernate, but I don't know what the benefits and disadvantages of each approach. I also know that in the background, Spring Data JPA will call Hibernate. So what is the best way I should use to query the database to get the best performance, Spring Data JPA or Hibernate or depending on the specific usage situation. Thanks very much
I think it is based on the requirements of your project.
You can find more answers to this question at StackOverflow.
I am currently using Spring 2 + Hibernate 3.
Question 1: What is the good reason to use hibernate framework within Spring's IoC?
Question 2: Why not separate hibernate framework from Spring's IoC framework?
Question 3: For those who experienced using hibernate in Spring 3, is there any pain? (I noted that Spring 3 has much lesser configuration)
The reason why I ask this question is that I think using hibernate within Spring's IoC caused hibernate to be tightly coupled with Spring and caused the configuration file to be much complicated. Please enlighten me.
Thanks to #Wand Maker.
I have found the answer I need in the link provided: http://static.springsource.org/spring/docs/3.0.x/reference/orm.html at the 13.3 Hibernate portion which explains the different ways to implement DAO using spring hibernate.
What is the difference between:
persistenc.xml can be configured with hibernate properties OR Javax.persistence properties.
What scenarios would you use either one.
I tried using javax.persistence but my spring app would not work.. changed it to hibernate and it started working.
javax.persistence is the standard. Hibernate is an implementation. If you are completely sure that your DB layer will always be handled by Hibernate, go ahead and configure using Hibernate. If not, use javax.persistence, so that you could change your DB layer in the future.
I am trying to develop Annotation based Spring Hibernate standalone application to connect to DB. I've gone through the some blogs and wondered like we should not make use of hibernateTemplate becoz coupling your application tightly to the spring framework. For this reason, Spring recommends that HibernateTemplate no longer be used.Further more my requirement is changed to Spring Hibernate with AOP using Declarative Transaction management.I am new to AOP concepts. Can any one please give an example on Spring Hibernate Connection through AOP. That would be a great help to me.
Thanks in advance.
If you are looking for exemples of project structures, you may want to use maven archetypes which provide you an already working Spring + Hibernate or Spring + JPA configuration.
They may provide you also a web layer (or not) but you can remove it if you want.
To try that, install maven and type:
mvn archetype:generate
By the way, I don't think using HibernateTemplate is a big deal. Many people still use it. But you'd better inject the Hibernate session factory and use contextual sessions with getCurrentSession()
I'd use JPA instead of plain Hibernate. You can of course use Hibernate as a provider. I guess that you know how to run Spring container in standalone application. Just follow the steps from documentation here. Use LocalContainerEntityManagerFactoryBean. Then read about transaction management.
There is a new feature that lets you start JPA without persistence.xml file. Read here.
If you still want to use plain Hibernate follow the docs.
Newbie here...
I'm working on a Spring MVC app and their JDBC api for data access. How would I go about saving data to multiple tables? The insertion needs to be such that if there's an error or something goes wrong, nothing gets inserted and rolled-back. Would this be Spring's transaction support? If so, the official documentation for transaction support is very confusing to me. Does anyone have a good source for learning how to do that?
I'm using Spring 3.1, Oracle 11g, and Tomcat 6.0
Yes, spring supports transaction. You can use DataSourceTransactionManager to configure your bean.IF you find xml mapping confusing you can use annotation #Transactional. Spring's annotation support for transactions are really simple. Spring in Action book has examples for transaction management.