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>
|
<dependency>
|
||||||
<groupId>org.hibernate.java-persistence</groupId>
|
<groupId>org.hibernate.java-persistence</groupId>
|
||||||
<artifactId>jpa-api</artifactId>
|
<artifactId>jpa-api</artifactId>
|
||||||
<version>2.0.Beta1</version>
|
<version>2.0.Beta2</version>
|
||||||
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,6 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate.java-persistence</groupId>
|
<groupId>org.hibernate.java-persistence</groupId>
|
||||||
<artifactId>jpa-api</artifactId>
|
<artifactId>jpa-api</artifactId>
|
||||||
<version>2.0.Beta1</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
|
@ -151,9 +150,9 @@
|
||||||
<version>3.2.0.ga</version>
|
<version>3.2.0.ga</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.persistence</groupId>
|
<groupId>org.hibernate.java-persistence</groupId>
|
||||||
<artifactId>persistence-api</artifactId>
|
<artifactId>jpa-api</artifactId>
|
||||||
<version>1.0</version>
|
<version>2.0.Beta2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ant</groupId>
|
<groupId>ant</groupId>
|
||||||
|
|
|
@ -24,14 +24,14 @@
|
||||||
package org.hibernate.envers;
|
package org.hibernate.envers;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
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.event.AuditEventListener;
|
||||||
import org.hibernate.envers.exception.AuditException;
|
import org.hibernate.envers.exception.AuditException;
|
||||||
import org.hibernate.envers.reader.AuditReaderImpl;
|
import org.hibernate.envers.reader.AuditReaderImpl;
|
||||||
import static org.hibernate.envers.tools.ArraysTools.arrayIncludesInstanceOf;
|
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.EventListeners;
|
||||||
import org.hibernate.event.PostInsertEventListener;
|
import org.hibernate.event.PostInsertEventListener;
|
||||||
|
|
||||||
|
@ -81,11 +81,17 @@ public class AuditReaderFactory {
|
||||||
* listeners aren't installed.
|
* listeners aren't installed.
|
||||||
*/
|
*/
|
||||||
public static AuditReader get(EntityManager entityManager) throws AuditException {
|
public static AuditReader get(EntityManager entityManager) throws AuditException {
|
||||||
try {
|
if (entityManager.getDelegate() instanceof Session) {
|
||||||
return get( entityManager.unwrap(Session.class) );
|
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!");
|
throw new AuditException("Hibernate EntityManager not present!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
package org.jboss.envers;
|
package org.jboss.envers;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.PersistenceException;
|
|
||||||
|
|
||||||
import org.hibernate.envers.event.AuditEventListener;
|
import org.hibernate.envers.event.AuditEventListener;
|
||||||
import org.hibernate.envers.reader.AuditReaderImpl;
|
import org.hibernate.envers.reader.AuditReaderImpl;
|
||||||
|
@ -82,11 +81,16 @@ public class VersionsReaderFactory {
|
||||||
* listeners aren't installed.
|
* listeners aren't installed.
|
||||||
*/
|
*/
|
||||||
public static VersionsReader get(EntityManager entityManager) throws VersionsException {
|
public static VersionsReader get(EntityManager entityManager) throws VersionsException {
|
||||||
try {
|
if (entityManager.getDelegate() instanceof Session) {
|
||||||
return get( entityManager.unwrap(Session.class) );
|
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!");
|
throw new VersionsException("Hibernate EntityManager not present!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
|
@ -25,7 +25,6 @@ package org.hibernate.envers.test.integration.flush;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.PersistenceException;
|
|
||||||
|
|
||||||
import org.hibernate.envers.test.AbstractEntityTest;
|
import org.hibernate.envers.test.AbstractEntityTest;
|
||||||
import org.hibernate.envers.test.entities.StrTestEntity;
|
import org.hibernate.envers.test.entities.StrTestEntity;
|
||||||
|
@ -46,12 +45,18 @@ public abstract class AbstractFlushTest extends AbstractEntityTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Session getSession(EntityManager em) {
|
private static Session getSession(EntityManager em) {
|
||||||
try {
|
Object delegate = em.getDelegate();
|
||||||
return em.unwrap( Session.class );
|
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")
|
@BeforeClass(dependsOnMethods = "init")
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class HsqlTest {
|
||||||
|
|
||||||
entityManager.getTransaction().begin();
|
entityManager.getTransaction().begin();
|
||||||
|
|
||||||
Session sesion = entityManager.unwrap(Session.class);
|
Session sesion = (Session) entityManager.getDelegate();
|
||||||
System.out.println(sesion.createQuery(
|
System.out.println(sesion.createQuery(
|
||||||
"select e from org.hibernate.envers.demo.Person_versions e " +
|
"select e from org.hibernate.envers.demo.Person_versions e " +
|
||||||
"where " +
|
"where " +
|
||||||
|
|
Loading…
Reference in New Issue