Skip to content

How can Spring 3.1 support hibernate 4 such as support Hibernate 3? [SPR-8940] #13580

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

Closed
spring-projects-issues opened this issue Dec 16, 2011 · 12 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Dec 16, 2011

weixing_zou opened SPR-8940 and commented

I can assign entityInterceptor and eventListeners to org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean, but there is no class org.springframework.orm.hibernate4.annotation.AnnotationSessionFactoryBean, and for org.springframework.orm.hibernate4.LocalSessionFactoryBean, there is no property entityInterceptor and eventListeners.
Then how can I upgrade to Hibernate 4 with Spring 3.1 under this situation?

For example:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="entityInterceptor" ref="entityInterceptor" />
<property name="eventListeners">
<map>
...
</map>
</property>
</bean>


Affects: 3.1 GA

Issue Links:

Referenced from: commits 23a941d, eb31528

8 votes, 12 watchers

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Good catch about "entityInterceptor" - I've added that to LocalSessionFactoryBean for Spring 3.1.1.

However, with respect to event listeners, Hibernate 4.0 changed its setup approach quite radically, and the documentation on it is very sparse. The old event registration methods on the Hibernate Configuration API do not exist anymore. We'll be researching what we can do about this.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Dec 25, 2011

Holger Stenzhorn commented

Hi Jürgen,

I do not know whether my issue is the same or related - or whether I am just not doing things correctly.

...but in order to employ Jasypt, I used the following for Hibernate3 in the ApplicationContext:

<property name="typeDefinitions">
  <list>
    <bean class="org.springframework.orm.hibernate3.TypeDefinitionBean">
      <property name="typeName" value="encryptedString"/>
      <property name="typeClass" value="org.jasypt.hibernate.type.EncryptedStringType"/>
      <property name="parameters">
        <props>
          <prop key="encryptorRegisteredName">hibernateStringEncryptor</prop>
        </props>
      </property>
    </bean>
  </list>
</property>

Now, in the LocalSessionFactoryBean for Hibernate 4, I cannot find the possibility to set type definitions (and there is no TypeDefinitionBean in that package as well).

As a replacement, I wanted to set the type definitions in the package-info.java of the model classes package but this seems to be not working because of issue #13233.

Regards,
Holger

@spring-projects-issues
Copy link
Collaborator Author

sreekanth commented

Hi Juergen,
We are using Hibernate 4 in our product, they have changed the whole way of constructing SessionFactory. Hibernate 4 will also support the older way of build SessionFactory but EventListner can't be configured using cfg files (see http://in.relation.to/Bloggers/EventListenerRegistration).Their major change will be happening at Hibernate 5 release with MetaDataSource and ServiceRegistry. As you said their documentation is not enough to help us in integrating Hibernate 4.

@spring-projects-issues
Copy link
Collaborator Author

Per Edlund commented

Hi!

Don't know if this belongs here, but I seam to get problems with hibernate4 and spring 3.1 when using the HibernateInterceptor from hibernate3 package, all other things from hibernate4 package.

Is there some configuration settings needed to make the sessionfactoryutils to create the correct session? I get a signature error (classic.session) instead of session

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Mixing and matching classes from the orm.hibernate3 and orm.hibernate4 packages is unfortunately not possible - due to signature changes in the Hibernate APIs, like the one that you encountered. The only thing we can do is to try to port further classes from orm.hibernate3 over to orm.hibernate4, provided that it is possible and that there is no better equivalent in the Hibernate 4 world.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Chris Beams commented

Resolved, with regard to the addition of entityInterceptor in LocalSessionFactoryBean

@spring-projects-issues
Copy link
Collaborator Author

Nils Breunese commented

I'm converting a project from Hibernate 3 to 4. I changed the org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean to org.springframework.orm.hibernate4.LocalSessionFactoryBean, but that class doesn't have an eventListeners property. How do I proceed?

@spring-projects-issues
Copy link
Collaborator Author

Anson Chiew commented

Hi Nilis, I am also looking for the solution. Have you found anything?

@spring-projects-issues
Copy link
Collaborator Author

weixing_zou commented

How about this issue? it seems that it has not been resolved yet. I can not upgrade to Hibernate 4.X yet.

@spring-projects-issues
Copy link
Collaborator Author

Chris Beams commented

I've created a new issue to address the inability to register event listeners against the hibernate 4 variant of LocalSessionFactoryBean. Interested parties, please watch/vote for this issue.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Jun 24, 2013

Ian Brandt commented

@Holger Stenzhorn: I've entered #15310 to cover the missing typeDefinitions property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants