Announcement Announcement Module
Collapse
No announcement yet.
Integration with Hibernate 4.1.11.Final release Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Integration with Hibernate 4.1.11.Final release

    Having trouble to use Spring injects Hibernate 4.1.11.Final release's EntityManager implementation,
    while it was fine integrated with Hibernate version 4.1.7.Final release.

    The trouble seems that Spring doesn't inject 4.1.11.Final version Hibernate's EntityManager properly.

    The config snippets as :

    <bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalContainerE ntityManagerFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="jpaVendorAdapter">
    <bean id="jpaVendorAdapter"
    class="org.springframework.orm.jpa.vendor.Hibernat eJpaVendorAdapter">
    ....
    </bean>

    <bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.Hibernat eJpaDialect" />

    <bean id="sharedEntityManagerBean"
    class="org.springframework.orm.jpa.support.SharedE ntityManagerBean">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionM anager">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
    <property name="jpaDialect" ref="jpaDialect" />
    <property name="nestedTransactionAllowed" value="true" />
    ...
    </bean>

    In the entity class:
    @PersistenceContext transient EntityManager entityManager;
    @Lob private Blob data;
    @Column(
    insertable = true,
    updatable = true,
    name = "fileName"
    )
    ...
    public void setData(InputStream data) throws IOException {

    // entityManager works fine with Hirbernate 4.1.7.Final release version

    // entityManager is null with Hibernate 4.1.11.Final release


    Session session = (Session)entityManager.getDelegate();
    LobCreator lobCreator = Hibernate.getLobCreator(session);
    this.data=lobCreator.createBlob(data, 0);

    }

    Any suggestions to work around this issue will be very appreciated!

  • #2
    This forum is for the Spring Integration project http://www.springsource.org/spring-integration/

    You should ask questions about Hibernate over on the Data Forum http://forum.springsource.org/forumdisplay.php?27-Data

    Comment

    Working...
    X