New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Hibernate 4.0.x [SPR-8096] #12751

Closed
spring-issuemaster opened this Issue Mar 29, 2011 · 13 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

spring-issuemaster commented Mar 29, 2011

Chris Beams opened SPR-8096 and commented

Introduce org.springframework.orm.hibernate4 packaging, and cut a clean implementation against Hibernate 4 APIs and SPIs. This is both desirable after years of Hibernate 3.2+ support as well as necessary given certain removals (such as AnnotationConfiguration) in the 4.x line.

Eliminate AnnotationSessionFactoryBuilder and AnnotationSessionFactoryBean in the 4.x line in favor of a SessionFactoryBuilder / LocalSessionFactoryBean that work against the unified org.hibernate.cfg.Configuration; consider support for Hibernate 4 Services (http://bit.ly/gnUAUI)

Eliminate HibernateTemplate and friends (e.g. HibernateCallback in favor of Spring's more modern 'Native Hibernate DAO' approach which has been used to good effect for quite a while.

org.springframework.orm.hibernate3 will remain, though possibly as a separate module (jar) from .orm.hibernate4 for dependency reasons.


8 votes, 10 watchers

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Aug 14, 2011

Kyrill Alyoshin commented

Hmm... Hibernate 4.0 will likely be released in September. I really hope it would not take too long for Spring to support it.

Our team really needs to move to Hibernate 4.0 as soon as possible (because of Hibernate Search 4.0, which will only work on Hibernate 4.0). Juergen, Chris, do you think it should be possible to run Hibernate 4.0 on top of existing Hibernate 3 AnnotationSessionFactoryBean? Or do we really have to wait for this feature to be implemented?

I would really appreciate your response.

Thanks!

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Aug 15, 2011

Juergen Hoeller commented

Good news: There is a working prototype already, and we decided to promote Hibernate 4.0 support to the Spring 3.1 feature set now. It won't be a direct 1:1 match with the orm.hibernate3 package but will provide everything needed for doing things the Hibernate 4 way within a Spring-based application. For example, there won't be a HibernateTemplate anymore, and we rely on Hibernate's own JTA support for JTA synchronization now. Also, LocalSessionFactoryBean got radically simplified for Hibernate 4... As an alternative, we will promote @Bean methods building a SessionFactory as well. We are still waiting for Hibernate 4.0 to stabilize its new configuration API though, since at the moment the only usable API is the deprecated Configuration class.

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Sep 10, 2011

Donnchadh O Donnabhain commented

It looks like Hibernate's new configuration API won't be ready until 4.1:
http://lists.jboss.org/pipermail/hibernate-dev/2011-August/007018.html

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Sep 15, 2011

Donnchadh O Donnabhain commented

With the release of Hibernate 4.0.0CR3 it looks like Hibernate 4.0 API/SPI has stabilized.
http://in.relation.to/Bloggers/HibernateCore400CR3Release
Is the aforementioned prototype on github or elsewhere? Compatibility with Hibernate 4.0 would be really nice to have for Spring 3.1.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Sep 15, 2011

Juergen Hoeller commented

I'm developing that prototype locally at the moment. It'll show up in the repo once Hibernate 4.0 goes final and can be added to our bundle repository; I guess that's just a few days away. I'll make sure to update our support package against Hibernate 4.0 CR3 in the meantime - thanks for raising it! And yes, Hibernate 4.0 support will definitely be in Spring 3.1 now. FYI, we're aiming for a Spring 3.1 RC1 release on October 11th.

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Oct 11, 2011

Juergen Hoeller commented

The initial cut of our "orm.hibernate4" package is in SVN in the meantime and will be part of Spring 3.1 RC1. However, since it hasn't been tested much yet, I expect significant refinements and additions in the upcoming RC2. Let me know what works or does not work for you, what you're missing, etc.

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Oct 12, 2011

Slawek Garwol commented

I think that support for integrators as spring beans will be most wanted feature

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Nov 9, 2011

John Kroubalkian commented

Above it says "Eliminate HibernateTemplate and friends (e.g. HibernateCallback in favor of Spring's more modern 'Native Hibernate DAO' approach which has been used to good effect for quite a while."

Can you provide a link to a description/example of using the 'Native Hibernate DAO' approach?

Thanks,

John

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Nov 9, 2011

John Kroubalkian commented

By "Native Hibernate DAO" approach, are you indicating a DAO object with injected SessionFactory, and then just using the Hibernate API directly?

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Nov 10, 2011

Chris Beams commented

@John, yes - by "Native Hibernate DAO", we simply mean injecting the SessionFactory and working against it directly. This is as opposed to working against Spring's HibernateTemplate.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Nov 22, 2011

Donnchadh O Donnabhain commented

With Hibernate 4.0CR6 I get the following exception:

java.lang.NoSuchMethodError: org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session;
	at org.springframework.orm.hibernate4.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:328)
	at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
	at org.springframework.test.context.transaction.TransactionalTestExecutionListener$TransactionContext.startTransaction(TransactionalTestExecutionListener.java:513)

It looks like org.springframework.orm.hibernate4.HibernateTransactionManager was compiled against Hibernate 3.x since SessionFactory.openSession() returns org.hibernate.Session in Hibernate 4.0 (in fact org.hibernate.classic.Session no longer exists).

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Nov 22, 2011

Chris Beams commented

Hi Donnchadh, see https://issues.springsource.org/browse/SPR-8776, which is already resolved.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Nov 22, 2011

Donnchadh O Donnabhain commented

Thanks Chris, I should have spotted that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment