ANN-831 - upgraded to the Beta2 version of JPA2 and reverted some code
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@16551 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
9d2b288c45
commit
062e0b5ecd
|
@ -58,7 +58,8 @@
|
|||
<dependency>
|
||||
<groupId>org.hibernate.java-persistence</groupId>
|
||||
<artifactId>jpa-api</artifactId>
|
||||
<version>2.0.Beta1</version>
|
||||
<version>2.0.Beta2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -72,7 +72,6 @@
|
|||
<dependency>
|
||||
<groupId>org.hibernate.java-persistence</groupId>
|
||||
<artifactId>jpa-api</artifactId>
|
||||
<version>2.0.Beta1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
|
@ -151,9 +150,9 @@
|
|||
<version>3.2.0.ga</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.persistence</groupId>
|
||||
<artifactId>persistence-api</artifactId>
|
||||
<version>1.0</version>
|
||||
<groupId>org.hibernate.java-persistence</groupId>
|
||||
<artifactId>jpa-api</artifactId>
|
||||
<version>2.0.Beta2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ant</groupId>
|
||||
|
|
|
@ -24,14 +24,14 @@
|
|||
package org.hibernate.envers;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.engine.SessionImplementor;
|
||||
import org.hibernate.envers.event.AuditEventListener;
|
||||
import org.hibernate.envers.exception.AuditException;
|
||||
import org.hibernate.envers.reader.AuditReaderImpl;
|
||||
import static org.hibernate.envers.tools.ArraysTools.arrayIncludesInstanceOf;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.engine.SessionImplementor;
|
||||
import org.hibernate.event.EventListeners;
|
||||
import org.hibernate.event.PostInsertEventListener;
|
||||
|
||||
|
@ -81,11 +81,17 @@ public class AuditReaderFactory {
|
|||
* listeners aren't installed.
|
||||
*/
|
||||
public static AuditReader get(EntityManager entityManager) throws AuditException {
|
||||
try {
|
||||
return get( entityManager.unwrap(Session.class) );
|
||||
if (entityManager.getDelegate() instanceof Session) {
|
||||
return get((Session) entityManager.getDelegate());
|
||||
}
|
||||
catch ( PersistenceException e ) {
|
||||
|
||||
if (entityManager.getDelegate() instanceof EntityManager) {
|
||||
entityManager = (EntityManager) entityManager.getDelegate();
|
||||
if (entityManager.getDelegate() instanceof Session) {
|
||||
return get((Session) entityManager.getDelegate());
|
||||
}
|
||||
}
|
||||
|
||||
throw new AuditException("Hibernate EntityManager not present!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
package org.jboss.envers;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
import org.hibernate.envers.event.AuditEventListener;
|
||||
import org.hibernate.envers.reader.AuditReaderImpl;
|
||||
|
@ -82,11 +81,16 @@ public class VersionsReaderFactory {
|
|||
* listeners aren't installed.
|
||||
*/
|
||||
public static VersionsReader get(EntityManager entityManager) throws VersionsException {
|
||||
try {
|
||||
return get( entityManager.unwrap(Session.class) );
|
||||
if (entityManager.getDelegate() instanceof Session) {
|
||||
return get((Session) entityManager.getDelegate());
|
||||
}
|
||||
catch ( PersistenceException e ) {
|
||||
|
||||
if (entityManager.getDelegate() instanceof EntityManager) {
|
||||
if (entityManager.getDelegate() instanceof Session) {
|
||||
return get((Session) entityManager.getDelegate());
|
||||
}
|
||||
}
|
||||
|
||||
throw new VersionsException("Hibernate EntityManager not present!");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -25,7 +25,6 @@ package org.hibernate.envers.test.integration.flush;
|
|||
|
||||
import java.io.IOException;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
import org.hibernate.envers.test.AbstractEntityTest;
|
||||
import org.hibernate.envers.test.entities.StrTestEntity;
|
||||
|
@ -46,12 +45,18 @@ public abstract class AbstractFlushTest extends AbstractEntityTest {
|
|||
}
|
||||
|
||||
private static Session getSession(EntityManager em) {
|
||||
try {
|
||||
return em.unwrap( Session.class );
|
||||
Object delegate = em.getDelegate();
|
||||
if (delegate instanceof Session) {
|
||||
return (Session) delegate;
|
||||
} else if (delegate instanceof EntityManager) {
|
||||
Object delegate2 = ((EntityManager) delegate).getDelegate();
|
||||
|
||||
if (delegate2 instanceof Session) {
|
||||
return (Session) delegate2;
|
||||
}
|
||||
catch ( PersistenceException e ) {
|
||||
throw new RuntimeException("Invalid entity manager", e);
|
||||
}
|
||||
|
||||
throw new RuntimeException("Invalid entity manager");
|
||||
}
|
||||
|
||||
@BeforeClass(dependsOnMethods = "init")
|
||||
|
|
|
@ -100,7 +100,7 @@ public class HsqlTest {
|
|||
|
||||
entityManager.getTransaction().begin();
|
||||
|
||||
Session sesion = entityManager.unwrap(Session.class);
|
||||
Session sesion = (Session) entityManager.getDelegate();
|
||||
System.out.println(sesion.createQuery(
|
||||
"select e from org.hibernate.envers.demo.Person_versions e " +
|
||||
"where " +
|
||||
|
|
Loading…
Reference in New Issue