[hibernate-issues] [Hibernate-JIRA] Commented: (EJB-267) FlushMode.MANUAL being ignored???

James Woodward (JIRA) noreply at atlassian.com
Thu Feb 8 05:42:42 EST 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/EJB-267?page=comments#action_26028 ] 

James Woodward commented on EJB-267:
------------------------------------

Cheers for that Christian, I tried using this code:

    public void init() {
        org.hibernate.Session session = (org.hibernate.Session) entityManager.getDelegate();
        session.setFlushMode(org.hibernate.FlushMode.MANUAL);
    }

But get a ClassCastException, as getDelegate() is returning an org.hibernate.ejb.EntityManagerImpl object.

The following appears to work though:

    public void init() {
        org.hibernate.Session session = ((org.hibernate.ejb.HibernateEntityManager) entityManager.getDelegate()).getSession();
        session.setFlushMode(org.hibernate.FlushMode.MANUAL);
    }

Is that a better way?

> FlushMode.MANUAL being ignored???
> ---------------------------------
>
>          Key: EJB-267
>          URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-267
>      Project: Hibernate Entity Manager
>         Type: Task

>   Components: EntityManager
>     Versions: 3.2.2
>  Environment: Hibernate Entity Manager 3.2.1.GA
>     Reporter: James Woodward

>
>
> The following code is advocated as best practice in the book "Java Persistence with Hibernate" for creating an extended persistence context in a SFSB, but the persistence property is currently being ignored.
> @PersistenceContext(type=PersistenceContextType.EXTENDED, properties=@PersistenceProperty(name="org.hibernate.flushMode", value="MANUAL"))
>     private EntityManager entityManager; 
> As a workaround you can set the flushMode in a business method using the following code:
>     public void init() {
>         org.hibernate.Session session = ((org.jboss.ejb3.entity.HibernateSession) entityManager).getHibernateSession();
>         session.setFlushMode(org.hibernate.FlushMode.MANUAL);
>     }
> See http://forum.hibernate.org/viewtopic.php?t=970727 for details.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list