HHH-4437:
- applying patches git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@17584 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
e1f0574cd1
commit
58fdaeb637
|
@ -58,7 +58,7 @@ import org.hibernate.type.Type;
|
|||
* @author Adam Warski (adam at warski dot org)
|
||||
*/
|
||||
public abstract class AbstractDelegateSessionImplementor implements SessionImplementor {
|
||||
private SessionImplementor delegate;
|
||||
protected SessionImplementor delegate;
|
||||
|
||||
public AbstractDelegateSessionImplementor(SessionImplementor delegate) {
|
||||
this.delegate = delegate;
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.hibernate.envers.entities.EntityConfiguration;
|
|||
import org.hibernate.envers.reader.AuditReaderImplementor;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.Session;
|
||||
|
||||
/**
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
|
@ -62,8 +61,7 @@ public class ToOneDelegateSessionImplementor extends AbstractDelegateSessionImpl
|
|||
if (notVersionedEntityConfiguration == null) {
|
||||
return versionsReader.find(entityClass, entityId, revision);
|
||||
} else {
|
||||
Session session = versionsReader.getSession();
|
||||
return session.get(entityClass, (Serializable) entityId);
|
||||
return delegate.immediateLoad(entityName, (Serializable) entityId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,8 +72,8 @@ public class UnversionedStrTestEntity {
|
|||
|
||||
UnversionedStrTestEntity that = (UnversionedStrTestEntity) o;
|
||||
|
||||
if (id != null ? !id.equals(that.id) : that.id != null) return false;
|
||||
if (str != null ? !str.equals(that.str) : that.str != null) return false;
|
||||
if (id != null ? !id.equals(that.getId()) : that.getId() != null) return false;
|
||||
if (str != null ? !str.equals(that.getStr()) : that.getStr() != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -88,4 +88,4 @@ public class UnversionedStrTestEntity {
|
|||
public String toString() {
|
||||
return "USTE(id = " + id + ", str = " + str + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public class TargetNotAuditedEntity {
|
|||
private String data;
|
||||
|
||||
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
private UnversionedStrTestEntity reference;
|
||||
|
||||
public TargetNotAuditedEntity() { }
|
||||
|
@ -96,8 +96,8 @@ public class TargetNotAuditedEntity {
|
|||
|
||||
TargetNotAuditedEntity that = (TargetNotAuditedEntity) o;
|
||||
|
||||
if (data != null ? !data.equals(that.data) : that.data != null) return false;
|
||||
if (id != null ? !id.equals(that.id) : that.id != null) return false;
|
||||
if (data != null ? !data.equals(that.getData()) : that.getData() != null) return false;
|
||||
if (id != null ? !id.equals(that.getId()) : that.getId() != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,11 @@ import org.hibernate.ejb.Ejb3Configuration;
|
|||
import org.hibernate.envers.test.AbstractEntityTest;
|
||||
import org.hibernate.envers.test.entities.UnversionedStrTestEntity;
|
||||
import org.hibernate.envers.test.entities.manytoone.unidirectional.TargetNotAuditedEntity;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.proxy.HibernateProxy;
|
||||
import org.hibernate.proxy.HibernateProxyHelper;
|
||||
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -129,6 +134,9 @@ public class RelationNotAuditedTarget extends AbstractEntityTest {
|
|||
|
||||
@Test
|
||||
public void testHistoryOfTnae1_id() {
|
||||
// load original "tnae1" TargetNotAuditedEntity to force load "str1" UnversionedStrTestEntity as Proxy
|
||||
TargetNotAuditedEntity original = getEntityManager().find(TargetNotAuditedEntity.class, tnae1_id);
|
||||
|
||||
UnversionedStrTestEntity uste1 = getEntityManager().find(UnversionedStrTestEntity.class, uste1_id);
|
||||
UnversionedStrTestEntity uste2 = getEntityManager().find(UnversionedStrTestEntity.class, uste2_id);
|
||||
|
||||
|
@ -141,6 +149,11 @@ public class RelationNotAuditedTarget extends AbstractEntityTest {
|
|||
assert rev2.getReference().equals(uste2);
|
||||
assert rev3.getReference().equals(uste2);
|
||||
assert rev4.getReference().equals(uste1);
|
||||
|
||||
assert original.getReference() instanceof HibernateProxy;
|
||||
assert UnversionedStrTestEntity.class.equals(Hibernate.getClass(original.getReference()));
|
||||
assert UnversionedStrTestEntity.class.equals(HibernateProxyHelper.getClassWithoutInitializingProxy(rev1.getReference()));
|
||||
assert UnversionedStrTestEntity.class.equals(Hibernate.getClass(rev1.getReference()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
<package name="org.hibernate.envers.test.integration.manytomany" />
|
||||
<package name="org.hibernate.envers.test.integration.manytomany.ternary" />
|
||||
<package name="org.hibernate.envers.test.integration.manytomany.unidirectional" />
|
||||
<package name="org.hibernate.envers.test.integration.manytoone.unidirectional" />
|
||||
<package name="org.hibernate.envers.test.integration.naming" />
|
||||
<package name="org.hibernate.envers.test.integration.naming.ids" />
|
||||
<package name="org.hibernate.envers.test.integration.notinsertable" />
|
||||
|
|
Loading…
Reference in New Issue