Author: hardy.ferentschik
Date: 2009-05-12 09:09:57 -0400 (Tue, 12 May 2009)
New Revision: 16551
Modified:
core/trunk/cache-jbosscache2/pom.xml
core/trunk/envers/pom.xml
core/trunk/envers/src/main/java/org/hibernate/envers/AuditReaderFactory.java
core/trunk/envers/src/main/java/org/jboss/envers/VersionsReaderFactory.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/flush/AbstractFlushTest.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/various/HsqlTest.java
Log:
ANN-831 - upgraded to the Beta2 version of JPA2 and reverted some code
Modified: core/trunk/cache-jbosscache2/pom.xml
===================================================================
--- core/trunk/cache-jbosscache2/pom.xml 2009-05-12 12:13:52 UTC (rev 16550)
+++ core/trunk/cache-jbosscache2/pom.xml 2009-05-12 13:09:57 UTC (rev 16551)
@@ -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>
Modified: core/trunk/envers/pom.xml
===================================================================
--- core/trunk/envers/pom.xml 2009-05-12 12:13:52 UTC (rev 16550)
+++ core/trunk/envers/pom.xml 2009-05-12 13:09:57 UTC (rev 16551)
@@ -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>
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/AuditReaderFactory.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/AuditReaderFactory.java 2009-05-12
12:13:52 UTC (rev 16550)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/AuditReaderFactory.java 2009-05-12
13:09:57 UTC (rev 16551)
@@ -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 @@
* listeners aren't installed.
*/
public static AuditReader get(EntityManager entityManager) throws AuditException {
- try {
- return get( entityManager.unwrap(Session.class) );
- }
- catch ( PersistenceException e ) {
- throw new AuditException("Hibernate EntityManager not present!");
- }
+ if (entityManager.getDelegate() instanceof Session) {
+ return get((Session) entityManager.getDelegate());
+ }
+
+ 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!");
}
}
Modified: core/trunk/envers/src/main/java/org/jboss/envers/VersionsReaderFactory.java
===================================================================
--- core/trunk/envers/src/main/java/org/jboss/envers/VersionsReaderFactory.java 2009-05-12
12:13:52 UTC (rev 16550)
+++ core/trunk/envers/src/main/java/org/jboss/envers/VersionsReaderFactory.java 2009-05-12
13:09:57 UTC (rev 16551)
@@ -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 @@
* listeners aren't installed.
*/
public static VersionsReader get(EntityManager entityManager) throws
VersionsException {
- try {
- return get( entityManager.unwrap(Session.class) );
- }
- catch ( PersistenceException e ) {
- throw new VersionsException("Hibernate EntityManager not present!");
- }
+ if (entityManager.getDelegate() instanceof Session) {
+ return get((Session) entityManager.getDelegate());
+ }
+
+ if (entityManager.getDelegate() instanceof EntityManager) {
+ if (entityManager.getDelegate() instanceof Session) {
+ return get((Session) entityManager.getDelegate());
+ }
+ }
+
+ throw new VersionsException("Hibernate EntityManager not present!");
}
}
\ No newline at end of file
Property changes on:
core/trunk/envers/src/main/java/org/jboss/envers/VersionsReaderFactory.java
___________________________________________________________________
Name: svn:mergeinfo
-
Modified:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/flush/AbstractFlushTest.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/flush/AbstractFlushTest.java 2009-05-12
12:13:52 UTC (rev 16550)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/flush/AbstractFlushTest.java 2009-05-12
13:09:57 UTC (rev 16551)
@@ -25,7 +25,6 @@
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 @@
}
private static Session getSession(EntityManager em) {
- try {
- return em.unwrap( Session.class );
- }
- catch ( PersistenceException e ) {
- throw new RuntimeException("Invalid entity manager", e);
- }
+ 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;
+ }
+ }
+
+ throw new RuntimeException("Invalid entity manager");
}
@BeforeClass(dependsOnMethods = "init")
Modified: core/trunk/envers/src/test/java/org/hibernate/envers/test/various/HsqlTest.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/various/HsqlTest.java 2009-05-12
12:13:52 UTC (rev 16550)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/various/HsqlTest.java 2009-05-12
13:09:57 UTC (rev 16551)
@@ -100,7 +100,7 @@
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 " +