I've been trying to get Hibernate 4 up and running in Jetty, however, the application I'm using specifies a deprecated TransactionManagerLookup (Bitronix).
I was wondering if there's a good alternative to use, as there is not one listed specifically for Jetty in the documentation (http://docs.jboss.org/hibernate/core/4.0/manual/en-US/html_single/#configuration-optional-transactionstrategy). Alternatively, can Bitronix be used for this in a way which is not deprecated.
Versions:
Jetty 6.1.18
Hibernate 4.0.0.Final
Spring 3.1.0.RELEASE
Hibernate 4 got its JTA code and configuration heavily reworked since 3.x. The Bitronix TM is not deprecated but the TransactionManagerLookup implementations are.
Have a look there to figure out what needs to be changed to be able to use BTM with Hibernate 4: http://old.nabble.com/Bitronix-Lookup-in-HIbernate-4-td33071521.html
Related
After upgrading to Java 17 and Spring Boot 3.0.1, jakarta is also replacing javax. You can add as many datasources as you like, as long as they share the same username/password and driveClassName. However, what if you have two datasources with different creds? There doesn't seem to be an equivalent to how javax handles this. i.e., see first answer here with the Config class...
Spring Boot configure and use two data sources
What is the jakarta equivalent or how do we configure this?
I am going to create simple rest service using spring 3 and hibernate 3. There is no chance for me to use higher version of spring due to legacy business component that is based on hibernate 3.
For such purposes I've tried to use SpringApplication.run, bet recieved following exception:
Exception in thread "main" java.lang.IllegalAccessError: tried to access method org.springframework.core.io.support.SpringFactoriesLoader.loadFactoryNames
Is it possible to use spring-boot-maven-plugin with old spring version? Would be good to know any alternative ways in this direction.
Spring Boot (and all the related tools, e.g the maven plugin) expect Spring v4 and above. Please see the official documentation here.
By default, Spring Boot 1.3.2.BUILD-SNAPSHOT requires Java 7 and Spring Framework 4.1.5 or above.
I just downloaded Hibernate 4.2.3 Final and see that it has several optional libraries, though I'm not sure what it uses them for or under what circumstances they are needed/desired:
jboss-logging-3.1.0.GA.jar - is this a native SLF4J binding? Is there a way to have Hibernate not use this for logging, and instead use SLF4J and a different binding? If so, how?
C3P0 and Proxool JARs are also optionally included; are these the only two connection pool frameworks that Hibernate can be configured to use? What if I wanted to use, day, BoneCP? What if I wanted to let JNDI (Tomcat/DBCP) decide what connection pool to use?
What is hibernate-entitymanager?
What is hibernate-envers?
Hibernate now uses jboss-logging, refer to: How do you configure logging in Hibernate 4 to use SLF4J
I never heard of others, I'm sure they are good for most of use cases. If you want to use Tomcat/DBCP you can use as a JTA datasource. I don't think there is a connection provider for hibernate 3 or 4. Source: http://wiki.apache.org/commons/DBCP/Hibernate
If you want to use the HibernateEntityManager instead the javax.persistence.EntityManager, you can have the jar on your classpath and code with it.
Envers is an "automagical" auditing/versioning extension, where you annotate the Entities with #Audited and during the transaction, the changes would be also persisted. There is more here http://www.jboss.org/envers.
I am using Hibernate 4 CR1. My application was previously using Spring hibernate support (for version 3).
I have not been able to find any information about this - is there any indication as to when (or which version) Spring will provide support for Hibernate 4?
UPDATE: Spring Framework 3.1 goes GA
You need to upgrade to Spring 3.1.0.RC1 released today:
Spring 3.1.0.RC1 Released:
Support for Hibernate 4.0 (up to date with 4.0 CR4)
As per comment of one of the guys is is involved in the spring project it seems that they started working on hibernate 4 support:
http://forum.springsource.org/showthread.php?115682-Migrating-application-context-configuration-to-Spring-3.1-and-Hibernate-4.0&p=382864#post382864
Quote from hib official docs:
Starting with version 3.0.1, Hibernate added the SessionFactory.getCurrentSession() method. Initially, this assumed usage of JTA transactions, where the JTA transaction defined both the scope and context of a current session. Given the maturity of the numerous stand-alone JTA TransactionManager implementations, most, if not all, applications should be using JTA transaction management, whether or not they are deployed into a J2EE container. Based on that, the JTA-based contextual sessions are all you need to use.
end of quotation
I use tomcat6 as a servlet container, and need to integrate Hibernate 3.2 into the project.
I found a document how to configure SessionFactory lookup through JNDI, though it does not work as expected.
Quote:
Hibernate works in any environment that uses JTA, in fact, we recommend to use JTA whenever possible as it is the standard Java transaction interface.
End of quote.
In hibernate config I indicate current_session_context_class = jta
and now I get an error "No TransactionManagerLookup specified".
The problem is that Tomcat does not support JTA, and to get it worked,
if I understand it correctly,
you need to add JOTM or other library to Tomcat.
But according to quote it is recommended to use JTA.
What can you recommend in this situation?
Your choices are pretty clear:
Either change to a servlet container that does support JTA
Find another transaction mechanism other than JTA, such as programatically controlling transactions yourself.
What can you recommend in this situation?
Do without JTA and use the Open Session In View pattern to handle the session.