svn merge -r 19697:19698 https://svn.jboss.org/repos/hibernate/core/branches/envers-hibernate-3.3 .
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@19699 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
e6d7d62bc0
commit
f0df563982
|
@ -100,12 +100,12 @@ public class EntityConfiguration {
|
|||
return propertyMapper;
|
||||
}
|
||||
|
||||
// For use by EntitiesConfigurations
|
||||
|
||||
String getParentEntityName() {
|
||||
public String getParentEntityName() {
|
||||
return parentEntityName;
|
||||
}
|
||||
|
||||
// For use by EntitiesConfigurations
|
||||
|
||||
String getVersionsEntityName() {
|
||||
return versionsEntityName;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.io.Serializable;
|
|||
import java.util.List;
|
||||
|
||||
import org.hibernate.envers.configuration.AuditConfiguration;
|
||||
import org.hibernate.envers.entities.EntityConfiguration;
|
||||
import org.hibernate.envers.entities.RelationDescription;
|
||||
import org.hibernate.envers.entities.RelationType;
|
||||
import org.hibernate.envers.entities.mapper.PersistentCollectionChangeData;
|
||||
|
@ -264,7 +265,7 @@ public class AuditEventListener implements PostInsertEventListener, PostUpdateEv
|
|||
|
||||
// Checking if this is not a "fake" many-to-one bidirectional relation. The relation description may be
|
||||
// null in case of collections of non-entities.
|
||||
RelationDescription rd = verCfg.getEntCfg().get(entityName).getRelationDescription(referencingPropertyName);
|
||||
RelationDescription rd = searchForRelationDescription(entityName, referencingPropertyName);
|
||||
if (rd != null && rd.getMappedByPropertyName() != null) {
|
||||
generateFakeBidirecationalRelationWorkUnits(auditProcess, newColl, oldColl, entityName,
|
||||
referencingPropertyName, event, rd);
|
||||
|
@ -285,6 +286,24 @@ public class AuditEventListener implements PostInsertEventListener, PostUpdateEv
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks up a relation description corresponding to the given property in the given entity. If no description is
|
||||
* found in the given entity, the parent entity is checked (so that inherited relations work).
|
||||
* @param entityName Name of the entity, in which to start looking.
|
||||
* @param referencingPropertyName The name of the property.
|
||||
* @return A found relation description corresponding to the given entity or {@code null}, if no description can
|
||||
* be found.
|
||||
*/
|
||||
private RelationDescription searchForRelationDescription(String entityName, String referencingPropertyName) {
|
||||
EntityConfiguration configuration = verCfg.getEntCfg().get(entityName);
|
||||
RelationDescription rd = configuration.getRelationDescription(referencingPropertyName);
|
||||
if (rd == null && configuration.getParentEntityName() != null) {
|
||||
return searchForRelationDescription(configuration.getParentEntityName(), referencingPropertyName);
|
||||
}
|
||||
|
||||
return rd;
|
||||
}
|
||||
|
||||
private CollectionEntry getCollectionEntry(AbstractCollectionEvent event) {
|
||||
return event.getSession().getPersistenceContext().getCollectionEntry(event.getCollection());
|
||||
}
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
package org.hibernate.envers.test.entities.onetomany.detached.inheritance;
|
||||
|
||||
import org.hibernate.envers.Audited;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* Entity for {@link org.hibernate.envers.test.integration.onetomany.detached.InheritanceIndexedJoinColumnBidirectionalList} test.
|
||||
* Child, owning side of the relation.
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
*/
|
||||
@Entity
|
||||
@Audited
|
||||
public class ChildIndexedListJoinColumnBidirectionalRefIngEntity extends ParentIndexedListJoinColumnBidirectionalRefIngEntity {
|
||||
private String data2;
|
||||
|
||||
public ChildIndexedListJoinColumnBidirectionalRefIngEntity() {
|
||||
}
|
||||
|
||||
public ChildIndexedListJoinColumnBidirectionalRefIngEntity(Integer id, String data, String data2, ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity... references) {
|
||||
super(id, data, references);
|
||||
this.data2 = data2;
|
||||
}
|
||||
|
||||
public ChildIndexedListJoinColumnBidirectionalRefIngEntity(String data, String data2, ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity... references) {
|
||||
super(data, references);
|
||||
this.data2 = data2;
|
||||
}
|
||||
|
||||
public String getData2() {
|
||||
return data2;
|
||||
}
|
||||
|
||||
public void setData2(String data2) {
|
||||
this.data2 = data2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof ChildIndexedListJoinColumnBidirectionalRefIngEntity)) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
ChildIndexedListJoinColumnBidirectionalRefIngEntity that = (ChildIndexedListJoinColumnBidirectionalRefIngEntity) o;
|
||||
|
||||
if (data2 != null ? !data2.equals(that.data2) : that.data2 != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + (data2 != null ? data2.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "ChildIndexedListJoinColumnBidirectionalRefIngEntity(id = " + getId() + ", data = " + getData() + ", data2 = " + data2 + ")";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package org.hibernate.envers.test.entities.onetomany.detached.inheritance;
|
||||
|
||||
import org.hibernate.annotations.IndexColumn;
|
||||
import org.hibernate.envers.AuditMappedBy;
|
||||
import org.hibernate.envers.Audited;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Entity for {@link org.hibernate.envers.test.integration.onetomany.detached.InheritanceIndexedJoinColumnBidirectionalList} test.
|
||||
* Parent, owning side of the relation.
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
*/
|
||||
@Entity
|
||||
@Audited
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
public abstract class ParentIndexedListJoinColumnBidirectionalRefIngEntity {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Integer id;
|
||||
|
||||
private String data;
|
||||
|
||||
@OneToMany
|
||||
@JoinColumn(name = "indexed_join_column")
|
||||
@IndexColumn(name = "indexed_index")
|
||||
@AuditMappedBy(mappedBy = "owner", positionMappedBy = "position")
|
||||
private List<ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity> references;
|
||||
|
||||
public ParentIndexedListJoinColumnBidirectionalRefIngEntity() { }
|
||||
|
||||
public ParentIndexedListJoinColumnBidirectionalRefIngEntity(Integer id, String data, ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity... references) {
|
||||
this.id = id;
|
||||
this.data = data;
|
||||
this.references = new ArrayList<ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity>();
|
||||
this.references.addAll(Arrays.asList(references));
|
||||
}
|
||||
|
||||
public ParentIndexedListJoinColumnBidirectionalRefIngEntity(String data, ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity... references) {
|
||||
this(null, data, references);
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public List<ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity> getReferences() {
|
||||
return references;
|
||||
}
|
||||
|
||||
public void setReferences(List<ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity> references) {
|
||||
this.references = references;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof ParentIndexedListJoinColumnBidirectionalRefIngEntity)) return false;
|
||||
|
||||
ParentIndexedListJoinColumnBidirectionalRefIngEntity that = (ParentIndexedListJoinColumnBidirectionalRefIngEntity) o;
|
||||
|
||||
if (data != null ? !data.equals(that.data) : that.data != null) return false;
|
||||
//noinspection RedundantIfStatement
|
||||
if (id != null ? !id.equals(that.id) : that.id != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int result;
|
||||
result = (id != null ? id.hashCode() : 0);
|
||||
result = 31 * result + (data != null ? data.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "ParentIndexedListJoinColumnBidirectionalRefIngEntity(id = " + id + ", data = " + data + ")";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package org.hibernate.envers.test.entities.onetomany.detached.inheritance;
|
||||
|
||||
import org.hibernate.envers.Audited;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* Entity for {@link org.hibernate.envers.test.integration.onetomany.detached.InheritanceIndexedJoinColumnBidirectionalList} test.
|
||||
* Owned side of the relation.
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
*/
|
||||
@Entity
|
||||
@Audited
|
||||
public class ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Integer id;
|
||||
|
||||
private String data;
|
||||
|
||||
@Column(name = "indexed_index", insertable = false, updatable = false)
|
||||
private Integer position;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "indexed_join_column", insertable = false, updatable = false)
|
||||
private ParentIndexedListJoinColumnBidirectionalRefIngEntity owner;
|
||||
|
||||
public ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity() { }
|
||||
|
||||
public ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity(Integer id, String data, ParentIndexedListJoinColumnBidirectionalRefIngEntity owner) {
|
||||
this.id = id;
|
||||
this.data = data;
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity(String data, ParentIndexedListJoinColumnBidirectionalRefIngEntity owner) {
|
||||
this.data = data;
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ParentIndexedListJoinColumnBidirectionalRefIngEntity getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(ParentIndexedListJoinColumnBidirectionalRefIngEntity owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public Integer getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public void setPosition(Integer position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity)) return false;
|
||||
|
||||
ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity that = (ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity) o;
|
||||
|
||||
if (data != null ? !data.equals(that.data) : that.data != null) return false;
|
||||
//noinspection RedundantIfStatement
|
||||
if (id != null ? !id.equals(that.id) : that.id != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int result;
|
||||
result = (id != null ? id.hashCode() : 0);
|
||||
result = 31 * result + (data != null ? data.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity(id = " + id + ", data = " + data + ")";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,253 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.envers.test.integration.onetomany.detached;
|
||||
|
||||
import org.hibernate.ejb.Ejb3Configuration;
|
||||
import org.hibernate.envers.test.AbstractEntityTest;
|
||||
import org.hibernate.envers.test.entities.onetomany.detached.inheritance.ChildIndexedListJoinColumnBidirectionalRefIngEntity;
|
||||
import org.hibernate.envers.test.entities.onetomany.detached.inheritance.ParentIndexedListJoinColumnBidirectionalRefIngEntity;
|
||||
import org.hibernate.envers.test.entities.onetomany.detached.inheritance.ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Test for a "fake" bidirectional mapping where one side uses @OneToMany+@JoinColumn (and thus owns the relation),
|
||||
* in the parent entity, and the other uses a @ManyToOne(insertable=false, updatable=false).
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
*/
|
||||
public class InheritanceIndexedJoinColumnBidirectionalList extends AbstractEntityTest {
|
||||
private Integer ed1_id;
|
||||
private Integer ed2_id;
|
||||
private Integer ed3_id;
|
||||
|
||||
private Integer ing1_id;
|
||||
private Integer ing2_id;
|
||||
|
||||
public void configure(Ejb3Configuration cfg) {
|
||||
cfg.addAnnotatedClass(ParentIndexedListJoinColumnBidirectionalRefIngEntity.class);
|
||||
cfg.addAnnotatedClass(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class);
|
||||
cfg.addAnnotatedClass(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class);
|
||||
}
|
||||
|
||||
@Test(enabled = true)
|
||||
public void createData() {
|
||||
EntityManager em = getEntityManager();
|
||||
|
||||
ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity ed1 = new ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity("ed1", null);
|
||||
ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity ed2 = new ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity("ed2", null);
|
||||
ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity ed3 = new ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity("ed3", null);
|
||||
|
||||
ChildIndexedListJoinColumnBidirectionalRefIngEntity ing1 = new ChildIndexedListJoinColumnBidirectionalRefIngEntity("coll1", "coll1bis", ed1, ed2, ed3);
|
||||
ChildIndexedListJoinColumnBidirectionalRefIngEntity ing2 = new ChildIndexedListJoinColumnBidirectionalRefIngEntity("coll1", "coll1bis");
|
||||
|
||||
// Revision 1 (ing1: ed1, ed2, ed3)
|
||||
em.getTransaction().begin();
|
||||
|
||||
em.persist(ed1);
|
||||
em.persist(ed2);
|
||||
em.persist(ed3);
|
||||
em.persist(ing1);
|
||||
em.persist(ing2);
|
||||
|
||||
em.getTransaction().commit();
|
||||
|
||||
// Revision 2 (ing1: ed1, ed3, ing2: ed2)
|
||||
em.getTransaction().begin();
|
||||
|
||||
ing1 = em.find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing1.getId());
|
||||
ing2 = em.find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing2.getId());
|
||||
ed2 = em.find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed2.getId());
|
||||
|
||||
ing1.getReferences().remove(ed2);
|
||||
ing2.getReferences().add(ed2);
|
||||
|
||||
em.getTransaction().commit();
|
||||
em.clear();
|
||||
|
||||
// Revision 3 (ing1: ed3, ed1, ing2: ed2)
|
||||
em.getTransaction().begin();
|
||||
|
||||
ing1 = em.find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing1.getId());
|
||||
ing2 = em.find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing2.getId());
|
||||
ed1 = em.find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed1.getId());
|
||||
ed2 = em.find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed2.getId());
|
||||
ed3 = em.find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed3.getId());
|
||||
|
||||
ing1.getReferences().remove(ed3);
|
||||
ing1.getReferences().add(0, ed3);
|
||||
|
||||
em.getTransaction().commit();
|
||||
em.clear();
|
||||
|
||||
// Revision 4 (ing1: ed2, ed3, ed1)
|
||||
em.getTransaction().begin();
|
||||
|
||||
ing1 = em.find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing1.getId());
|
||||
ing2 = em.find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing2.getId());
|
||||
ed1 = em.find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed1.getId());
|
||||
ed2 = em.find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed2.getId());
|
||||
ed3 = em.find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed3.getId());
|
||||
|
||||
ing2.getReferences().remove(ed2);
|
||||
ing1.getReferences().add(0, ed2);
|
||||
|
||||
em.getTransaction().commit();
|
||||
em.clear();
|
||||
|
||||
//
|
||||
|
||||
ing1_id = ing1.getId();
|
||||
ing2_id = ing2.getId();
|
||||
|
||||
ed1_id = ed1.getId();
|
||||
ed2_id = ed2.getId();
|
||||
ed3_id = ed3.getId();
|
||||
}
|
||||
|
||||
@Test(enabled = true, dependsOnMethods = "createData")
|
||||
public void testRevisionsCounts() {
|
||||
assertEquals(Arrays.asList(1, 2, 3, 4), getAuditReader().getRevisions(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing1_id));
|
||||
assertEquals(Arrays.asList(1, 2, 4), getAuditReader().getRevisions(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing2_id));
|
||||
|
||||
assertEquals(Arrays.asList(1, 3, 4), getAuditReader().getRevisions(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed1_id));
|
||||
assertEquals(Arrays.asList(1, 2, 4), getAuditReader().getRevisions(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed2_id));
|
||||
assertEquals(Arrays.asList(1, 2, 3, 4), getAuditReader().getRevisions(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed3_id));
|
||||
}
|
||||
|
||||
@Test(enabled = true, dependsOnMethods = "createData")
|
||||
public void testHistoryOfIng1() {
|
||||
ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity ed1 = getEntityManager().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed1_id);
|
||||
ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity ed2 = getEntityManager().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed2_id);
|
||||
ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity ed3 = getEntityManager().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed3_id);
|
||||
|
||||
ChildIndexedListJoinColumnBidirectionalRefIngEntity rev1 = getAuditReader().find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing1_id, 1);
|
||||
ChildIndexedListJoinColumnBidirectionalRefIngEntity rev2 = getAuditReader().find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing1_id, 2);
|
||||
ChildIndexedListJoinColumnBidirectionalRefIngEntity rev3 = getAuditReader().find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing1_id, 3);
|
||||
ChildIndexedListJoinColumnBidirectionalRefIngEntity rev4 = getAuditReader().find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing1_id, 4);
|
||||
|
||||
assertEquals(rev1.getReferences().size(), 3);
|
||||
assertEquals(rev1.getReferences().get(0), ed1);
|
||||
assertEquals(rev1.getReferences().get(1), ed2);
|
||||
assertEquals(rev1.getReferences().get(2), ed3);
|
||||
|
||||
assertEquals(rev2.getReferences().size(), 2);
|
||||
assertEquals(rev2.getReferences().get(0), ed1);
|
||||
assertEquals(rev2.getReferences().get(1), ed3);
|
||||
|
||||
assertEquals(rev3.getReferences().size(), 2);
|
||||
assertEquals(rev3.getReferences().get(0), ed3);
|
||||
assertEquals(rev3.getReferences().get(1), ed1);
|
||||
|
||||
assertEquals(rev4.getReferences().size(), 3);
|
||||
assertEquals(rev4.getReferences().get(0), ed2);
|
||||
assertEquals(rev4.getReferences().get(1), ed3);
|
||||
assertEquals(rev4.getReferences().get(2), ed1);
|
||||
}
|
||||
|
||||
@Test(enabled = true, dependsOnMethods = "createData")
|
||||
public void testHistoryOfIng2() {
|
||||
ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity ed2 = getEntityManager().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed2_id);
|
||||
|
||||
ChildIndexedListJoinColumnBidirectionalRefIngEntity rev1 = getAuditReader().find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing2_id, 1);
|
||||
ChildIndexedListJoinColumnBidirectionalRefIngEntity rev2 = getAuditReader().find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing2_id, 2);
|
||||
ChildIndexedListJoinColumnBidirectionalRefIngEntity rev3 = getAuditReader().find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing2_id, 3);
|
||||
ChildIndexedListJoinColumnBidirectionalRefIngEntity rev4 = getAuditReader().find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing2_id, 4);
|
||||
|
||||
assertEquals(rev1.getReferences().size(), 0);
|
||||
|
||||
assertEquals(rev2.getReferences().size(), 1);
|
||||
assertEquals(rev2.getReferences().get(0), ed2);
|
||||
|
||||
assertEquals(rev3.getReferences().size(), 1);
|
||||
assertEquals(rev3.getReferences().get(0), ed2);
|
||||
|
||||
assertEquals(rev4.getReferences().size(), 0);
|
||||
}
|
||||
|
||||
@Test(enabled = true, dependsOnMethods = "createData")
|
||||
public void testHistoryOfEd1() {
|
||||
ChildIndexedListJoinColumnBidirectionalRefIngEntity ing1 = getEntityManager().find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing1_id);
|
||||
|
||||
ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity rev1 = getAuditReader().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed1_id, 1);
|
||||
ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity rev2 = getAuditReader().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed1_id, 2);
|
||||
ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity rev3 = getAuditReader().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed1_id, 3);
|
||||
ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity rev4 = getAuditReader().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed1_id, 4);
|
||||
|
||||
assertTrue(rev1.getOwner().equals(ing1));
|
||||
assertTrue(rev2.getOwner().equals(ing1));
|
||||
assertTrue(rev3.getOwner().equals(ing1));
|
||||
assertTrue(rev4.getOwner().equals(ing1));
|
||||
|
||||
assertEquals(rev1.getPosition(), new Integer(0));
|
||||
assertEquals(rev2.getPosition(), new Integer(0));
|
||||
assertEquals(rev3.getPosition(), new Integer(1));
|
||||
assertEquals(rev4.getPosition(), new Integer(2));
|
||||
}
|
||||
|
||||
@Test(enabled = true, dependsOnMethods = "createData")
|
||||
public void testHistoryOfEd2() {
|
||||
ChildIndexedListJoinColumnBidirectionalRefIngEntity ing1 = getEntityManager().find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing1_id);
|
||||
ChildIndexedListJoinColumnBidirectionalRefIngEntity ing2 = getEntityManager().find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing2_id);
|
||||
|
||||
ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity rev1 = getAuditReader().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed2_id, 1);
|
||||
ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity rev2 = getAuditReader().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed2_id, 2);
|
||||
ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity rev3 = getAuditReader().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed2_id, 3);
|
||||
ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity rev4 = getAuditReader().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed2_id, 4);
|
||||
|
||||
assertTrue(rev1.getOwner().equals(ing1));
|
||||
assertTrue(rev2.getOwner().equals(ing2));
|
||||
assertTrue(rev3.getOwner().equals(ing2));
|
||||
assertTrue(rev4.getOwner().equals(ing1));
|
||||
|
||||
assertEquals(rev1.getPosition(), new Integer(1));
|
||||
assertEquals(rev2.getPosition(), new Integer(0));
|
||||
assertEquals(rev3.getPosition(), new Integer(0));
|
||||
assertEquals(rev4.getPosition(), new Integer(0));
|
||||
}
|
||||
|
||||
@Test(enabled = true, dependsOnMethods = "createData")
|
||||
public void testHistoryOfEd3() {
|
||||
ChildIndexedListJoinColumnBidirectionalRefIngEntity ing1 = getEntityManager().find(ChildIndexedListJoinColumnBidirectionalRefIngEntity.class, ing1_id);
|
||||
|
||||
ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity rev1 = getAuditReader().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed3_id, 1);
|
||||
ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity rev2 = getAuditReader().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed3_id, 2);
|
||||
ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity rev3 = getAuditReader().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed3_id, 3);
|
||||
ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity rev4 = getAuditReader().find(ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity.class, ed3_id, 4);
|
||||
|
||||
assertTrue(rev1.getOwner().equals(ing1));
|
||||
assertTrue(rev2.getOwner().equals(ing1));
|
||||
assertTrue(rev3.getOwner().equals(ing1));
|
||||
assertTrue(rev4.getOwner().equals(ing1));
|
||||
|
||||
assertEquals(rev1.getPosition(), new Integer(2));
|
||||
assertEquals(rev2.getPosition(), new Integer(1));
|
||||
assertEquals(rev3.getPosition(), new Integer(0));
|
||||
assertEquals(rev4.getPosition(), new Integer(1));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue