HHH-6349 - Test cleanup
This commit is contained in:
parent
7b093fbc31
commit
0e3fe2b3d5
|
@ -3,7 +3,6 @@ package org.hibernate.envers.test.entities.collection;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
@ -15,10 +14,12 @@ import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.Version;
|
import javax.persistence.Version;
|
||||||
|
|
||||||
@Entity
|
import org.hibernate.envers.AuditJoinTable;
|
||||||
@org.hibernate.envers.Audited
|
import org.hibernate.envers.Audited;
|
||||||
public class MultipleCollectionEntity {
|
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Audited
|
||||||
|
public class MultipleCollectionEntity {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "ID", length = 10)
|
@Column(name = "ID", length = 10)
|
||||||
|
@ -33,12 +34,12 @@ public class MultipleCollectionEntity {
|
||||||
|
|
||||||
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
|
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
|
||||||
@JoinColumn(name = "MCE_ID", nullable = false)
|
@JoinColumn(name = "MCE_ID", nullable = false)
|
||||||
@org.hibernate.envers.AuditJoinTable(name = "MCE_RE1_AUD", inverseJoinColumns = @JoinColumn(name = "RE1_ID"))
|
@AuditJoinTable(name = "MCE_RE1_AUD", inverseJoinColumns = @JoinColumn(name = "RE1_ID"))
|
||||||
private List<MultipleCollectionRefEntity1> refEntities1 = new ArrayList<MultipleCollectionRefEntity1>();
|
private List<MultipleCollectionRefEntity1> refEntities1 = new ArrayList<MultipleCollectionRefEntity1>();
|
||||||
|
|
||||||
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
|
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
|
||||||
@JoinColumn(name = "MCE_ID", nullable = false)
|
@JoinColumn(name = "MCE_ID", nullable = false)
|
||||||
@org.hibernate.envers.AuditJoinTable(name = "MCE_RE2_AUD", inverseJoinColumns = @JoinColumn(name = "RE2_ID"))
|
@AuditJoinTable(name = "MCE_RE2_AUD", inverseJoinColumns = @JoinColumn(name = "RE2_ID"))
|
||||||
private List<MultipleCollectionRefEntity2> refEntities2 = new ArrayList<MultipleCollectionRefEntity2>();
|
private List<MultipleCollectionRefEntity2> refEntities2 = new ArrayList<MultipleCollectionRefEntity2>();
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
|
@ -89,42 +90,34 @@ public class MultipleCollectionEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public boolean equals(Object o) {
|
||||||
final int prime = 31;
|
if ( this == o ) {
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((text == null) ? 0 : text.hashCode());
|
|
||||||
result = prime * result
|
|
||||||
+ ((refEntities1 == null) ? 0 : refEntities1.hashCode());
|
|
||||||
result = prime * result
|
|
||||||
+ ((refEntities2 == null) ? 0 : refEntities2.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (this == obj)
|
|
||||||
return true;
|
return true;
|
||||||
if (obj == null)
|
}
|
||||||
|
if ( ! ( o instanceof MultipleCollectionEntity ) ) {
|
||||||
return false;
|
return false;
|
||||||
if (getClass() != obj.getClass())
|
}
|
||||||
|
|
||||||
|
MultipleCollectionEntity that = (MultipleCollectionEntity) o;
|
||||||
|
|
||||||
|
if ( refEntities1 != null ? !refEntities1.equals( that.refEntities1 ) : that.refEntities1 != null ) {
|
||||||
return false;
|
return false;
|
||||||
MultipleCollectionEntity other = (MultipleCollectionEntity) obj;
|
}
|
||||||
if (text == null) {
|
if ( refEntities2 != null ? !refEntities2.equals( that.refEntities2 ) : that.refEntities2 != null ) {
|
||||||
if (other.text != null)
|
|
||||||
return false;
|
|
||||||
} else if (!text.equals(other.text))
|
|
||||||
return false;
|
return false;
|
||||||
if (refEntities1 == null) {
|
}
|
||||||
if (other.refEntities1 != null)
|
if ( text != null ? !text.equals( that.text ) : that.text != null ) {
|
||||||
return false;
|
|
||||||
} else if (!refEntities1.equals(other.refEntities1))
|
|
||||||
return false;
|
|
||||||
if (refEntities2 == null) {
|
|
||||||
if (other.refEntities2 != null)
|
|
||||||
return false;
|
|
||||||
} else if (!refEntities2.equals(other.refEntities2))
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = text != null ? text.hashCode() : 0;
|
||||||
|
result = 31 * result + ( refEntities1 != null ? refEntities1.hashCode() : 0 );
|
||||||
|
result = 31 * result + ( refEntities2 != null ? refEntities2.hashCode() : 0 );
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -9,12 +9,13 @@ import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.Version;
|
import javax.persistence.Version;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.ForeignKey;
|
||||||
|
import org.hibernate.envers.Audited;
|
||||||
import org.hibernate.envers.NotAudited;
|
import org.hibernate.envers.NotAudited;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@org.hibernate.envers.Audited
|
@Audited
|
||||||
public class MultipleCollectionRefEntity1 {
|
public class MultipleCollectionRefEntity1 {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "ID", length = 10)
|
@Column(name = "ID", length = 10)
|
||||||
|
@ -29,7 +30,7 @@ public class MultipleCollectionRefEntity1 {
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "MCE_ID", nullable = false, insertable = false, updatable = false)
|
@JoinColumn(name = "MCE_ID", nullable = false, insertable = false, updatable = false)
|
||||||
@org.hibernate.annotations.ForeignKey(name = "FK_RE1_MCE")
|
@ForeignKey(name = "FK_RE1_MCE")
|
||||||
@NotAudited
|
@NotAudited
|
||||||
private MultipleCollectionEntity multipleCollectionEntity;
|
private MultipleCollectionEntity multipleCollectionEntity;
|
||||||
|
|
||||||
|
@ -57,8 +58,7 @@ public class MultipleCollectionRefEntity1 {
|
||||||
return multipleCollectionEntity;
|
return multipleCollectionEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMultipleCollectionEntity(
|
public void setMultipleCollectionEntity(MultipleCollectionEntity multipleCollectionEntity) {
|
||||||
MultipleCollectionEntity multipleCollectionEntity) {
|
|
||||||
this.multipleCollectionEntity = multipleCollectionEntity;
|
this.multipleCollectionEntity = multipleCollectionEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,28 +78,25 @@ public class MultipleCollectionRefEntity1 {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public boolean equals(Object o) {
|
||||||
final int prime = 31;
|
if ( this == o ) {
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((text == null) ? 0 : text.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (this == obj)
|
|
||||||
return true;
|
return true;
|
||||||
if (obj == null)
|
}
|
||||||
|
if ( ! ( o instanceof MultipleCollectionRefEntity1 ) ) {
|
||||||
return false;
|
return false;
|
||||||
if (getClass() != obj.getClass())
|
}
|
||||||
return false;
|
|
||||||
MultipleCollectionRefEntity1 other = (MultipleCollectionRefEntity1) obj;
|
MultipleCollectionRefEntity1 that = (MultipleCollectionRefEntity1) o;
|
||||||
if (text == null) {
|
|
||||||
if (other.text != null)
|
if ( text != null ? !text.equals( that.text ) : that.text != null ) {
|
||||||
return false;
|
|
||||||
} else if (!text.equals(other.text))
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return text != null ? text.hashCode() : 0;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -9,12 +9,13 @@ import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.Version;
|
import javax.persistence.Version;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.ForeignKey;
|
||||||
|
import org.hibernate.envers.Audited;
|
||||||
import org.hibernate.envers.NotAudited;
|
import org.hibernate.envers.NotAudited;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@org.hibernate.envers.Audited
|
@Audited
|
||||||
public class MultipleCollectionRefEntity2 {
|
public class MultipleCollectionRefEntity2 {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "ID", length = 10)
|
@Column(name = "ID", length = 10)
|
||||||
|
@ -29,7 +30,7 @@ public class MultipleCollectionRefEntity2 {
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "MCE_ID", nullable = false, insertable = false, updatable = false)
|
@JoinColumn(name = "MCE_ID", nullable = false, insertable = false, updatable = false)
|
||||||
@org.hibernate.annotations.ForeignKey(name = "FK_RE2_MCE")
|
@ForeignKey(name = "FK_RE2_MCE")
|
||||||
@NotAudited
|
@NotAudited
|
||||||
private MultipleCollectionEntity multipleCollectionEntity;
|
private MultipleCollectionEntity multipleCollectionEntity;
|
||||||
|
|
||||||
|
@ -57,8 +58,7 @@ public class MultipleCollectionRefEntity2 {
|
||||||
return multipleCollectionEntity;
|
return multipleCollectionEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMultipleCollectionEntity(
|
public void setMultipleCollectionEntity(MultipleCollectionEntity multipleCollectionEntity) {
|
||||||
MultipleCollectionEntity multipleCollectionEntity) {
|
|
||||||
this.multipleCollectionEntity = multipleCollectionEntity;
|
this.multipleCollectionEntity = multipleCollectionEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,28 +78,25 @@ public class MultipleCollectionRefEntity2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public boolean equals(Object o) {
|
||||||
final int prime = 31;
|
if ( this == o ) {
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((text == null) ? 0 : text.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (this == obj)
|
|
||||||
return true;
|
return true;
|
||||||
if (obj == null)
|
}
|
||||||
|
if ( ! ( o instanceof MultipleCollectionRefEntity2 ) ) {
|
||||||
return false;
|
return false;
|
||||||
if (getClass() != obj.getClass())
|
}
|
||||||
return false;
|
|
||||||
MultipleCollectionRefEntity2 other = (MultipleCollectionRefEntity2) obj;
|
MultipleCollectionRefEntity2 that = (MultipleCollectionRefEntity2) o;
|
||||||
if (text == null) {
|
|
||||||
if (other.text != null)
|
if ( text != null ? !text.equals( that.text ) : that.text != null ) {
|
||||||
return false;
|
|
||||||
} else if (!text.equals(other.text))
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return text != null ? text.hashCode() : 0;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,30 +1,29 @@
|
||||||
package org.hibernate.envers.test.integration.collection;
|
package org.hibernate.envers.test.integration.collection;
|
||||||
|
|
||||||
import static org.hibernate.envers.test.EnversTestingJtaBootstrap.tryCommit;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.Query;
|
import javax.persistence.Query;
|
||||||
|
import javax.transaction.Status;
|
||||||
import javax.transaction.TransactionManager;
|
import javax.transaction.TransactionManager;
|
||||||
|
|
||||||
import org.hibernate.ejb.Ejb3Configuration;
|
import org.junit.Test;
|
||||||
import org.hibernate.envers.DefaultRevisionEntity;
|
|
||||||
import org.hibernate.envers.RevisionType;
|
import org.hibernate.envers.RevisionType;
|
||||||
import org.hibernate.envers.internal.EnversMessageLogger;
|
import org.hibernate.envers.enhanced.SequenceIdRevisionEntity;
|
||||||
import org.hibernate.envers.test.AbstractEntityTest;
|
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
|
||||||
import org.hibernate.envers.test.EnversTestingJtaBootstrap;
|
|
||||||
import org.hibernate.envers.test.Priority;
|
import org.hibernate.envers.test.Priority;
|
||||||
import org.hibernate.envers.test.entities.collection.MultipleCollectionEntity;
|
import org.hibernate.envers.test.entities.collection.MultipleCollectionEntity;
|
||||||
import org.hibernate.envers.test.entities.collection.MultipleCollectionRefEntity1;
|
import org.hibernate.envers.test.entities.collection.MultipleCollectionRefEntity1;
|
||||||
import org.hibernate.envers.test.entities.collection.MultipleCollectionRefEntity2;
|
import org.hibernate.envers.test.entities.collection.MultipleCollectionRefEntity2;
|
||||||
import org.jboss.logging.Logger;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.junit.Test;
|
import org.hibernate.testing.jta.TestingJtaBootstrap;
|
||||||
|
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the audit history of a detached entity with multiple collections that is
|
* Test the audit history of a detached entity with multiple collections that is
|
||||||
|
@ -32,32 +31,32 @@ import org.junit.Test;
|
||||||
*
|
*
|
||||||
* @author Erik-Berndt Scheper
|
* @author Erik-Berndt Scheper
|
||||||
*/
|
*/
|
||||||
public class DetachedMultipleCollectionChangeTest extends AbstractEntityTest {
|
@TestForIssue(jiraKey = "HHH-6349")
|
||||||
|
public class DetachedMultipleCollectionChangeTest extends BaseEnversJPAFunctionalTestCase {
|
||||||
|
private TransactionManager tm = null;
|
||||||
|
|
||||||
public static final EnversMessageLogger LOG = Logger.getMessageLogger(
|
private Long mceId1 = null;
|
||||||
EnversMessageLogger.class,
|
private Long re1Id1 = null;
|
||||||
DetachedMultipleCollectionChangeTest.class.getName());
|
private Long re1Id2 = null;
|
||||||
|
private Long re1Id3 = null;
|
||||||
|
private Long re2Id1 = null;
|
||||||
|
private Long re2Id2 = null;
|
||||||
|
private Long re2Id3 = null;
|
||||||
|
|
||||||
private TransactionManager tm;
|
@Override
|
||||||
|
protected Class<?>[] getAnnotatedClasses() {
|
||||||
private Long mceId1;
|
return new Class<?>[] {
|
||||||
private Long re1Id1;
|
MultipleCollectionEntity.class,
|
||||||
private Long re1Id2;
|
MultipleCollectionRefEntity1.class,
|
||||||
private Long re1Id3;
|
MultipleCollectionRefEntity2.class
|
||||||
private Long re2Id1;
|
};
|
||||||
private Long re2Id2;
|
|
||||||
private Long re2Id3;
|
|
||||||
|
|
||||||
public void configure(Ejb3Configuration cfg) {
|
|
||||||
cfg.addAnnotatedClass(MultipleCollectionEntity.class);
|
|
||||||
cfg.addAnnotatedClass(MultipleCollectionRefEntity1.class);
|
|
||||||
cfg.addAnnotatedClass(MultipleCollectionRefEntity2.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addConfigurationProperties(Properties configuration) {
|
protected void addConfigOptions(Map options) {
|
||||||
super.addConfigurationProperties(configuration);
|
super.addConfigOptions( options );
|
||||||
tm = EnversTestingJtaBootstrap.updateConfigAndCreateTM(configuration);
|
TestingJtaBootstrap.prepare( options );
|
||||||
|
tm = TestingJtaPlatformImpl.INSTANCE.getTransactionManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -69,187 +68,150 @@ public class DetachedMultipleCollectionChangeTest extends AbstractEntityTest {
|
||||||
MultipleCollectionRefEntity2 re2_1, updatedRe2_1, re2_2, re2_3;
|
MultipleCollectionRefEntity2 re2_1, updatedRe2_1, re2_2, re2_3;
|
||||||
|
|
||||||
tm.begin();
|
tm.begin();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
newEntityManager();
|
em = createIsolatedEntityManager();
|
||||||
em = getEntityManager();
|
|
||||||
em.joinTransaction();
|
em.joinTransaction();
|
||||||
mce = new MultipleCollectionEntity();
|
mce = new MultipleCollectionEntity();
|
||||||
mce.setText("MultipleCollectionEntity-1");
|
mce.setText( "MultipleCollectionEntity-1" );
|
||||||
em.persist(mce);
|
em.persist( mce );
|
||||||
mceId1 = mce.getId();
|
mceId1 = mce.getId();
|
||||||
|
|
||||||
} finally {
|
|
||||||
tryCommit(tm);
|
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
assertNotNull(mceId1);
|
tryCommit( tm );
|
||||||
|
}
|
||||||
//
|
assertNotNull( mceId1 );
|
||||||
|
|
||||||
tm.begin();
|
tm.begin();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
newEntityManager();
|
em = createIsolatedEntityManager();
|
||||||
em = getEntityManager();
|
|
||||||
em.joinTransaction();
|
em.joinTransaction();
|
||||||
|
|
||||||
// mce = em.find(MultipleCollectionEntity.class, mceId1);
|
|
||||||
// mce = em.merge(mce);
|
|
||||||
|
|
||||||
re1_1 = new MultipleCollectionRefEntity1();
|
re1_1 = new MultipleCollectionRefEntity1();
|
||||||
re1_1.setText("MultipleCollectionRefEntity1-1");
|
re1_1.setText( "MultipleCollectionRefEntity1-1" );
|
||||||
re1_1.setMultipleCollectionEntity(mce);
|
re1_1.setMultipleCollectionEntity( mce );
|
||||||
|
|
||||||
re1_2 = new MultipleCollectionRefEntity1();
|
re1_2 = new MultipleCollectionRefEntity1();
|
||||||
re1_2.setText("MultipleCollectionRefEntity1-2");
|
re1_2.setText( "MultipleCollectionRefEntity1-2" );
|
||||||
re1_2.setMultipleCollectionEntity(mce);
|
re1_2.setMultipleCollectionEntity( mce );
|
||||||
|
|
||||||
mce.addRefEntity1(re1_1);
|
mce.addRefEntity1( re1_1 );
|
||||||
mce.addRefEntity1(re1_2);
|
mce.addRefEntity1( re1_2 );
|
||||||
|
|
||||||
re2_1 = new MultipleCollectionRefEntity2();
|
re2_1 = new MultipleCollectionRefEntity2();
|
||||||
re2_1.setText("MultipleCollectionRefEntity2-1");
|
re2_1.setText( "MultipleCollectionRefEntity2-1" );
|
||||||
re2_1.setMultipleCollectionEntity(mce);
|
re2_1.setMultipleCollectionEntity( mce );
|
||||||
|
|
||||||
re2_2 = new MultipleCollectionRefEntity2();
|
re2_2 = new MultipleCollectionRefEntity2();
|
||||||
re2_2.setText("MultipleCollectionRefEntity2-2");
|
re2_2.setText( "MultipleCollectionRefEntity2-2" );
|
||||||
re2_2.setMultipleCollectionEntity(mce);
|
re2_2.setMultipleCollectionEntity( mce );
|
||||||
|
|
||||||
mce.addRefEntity2(re2_1);
|
mce.addRefEntity2( re2_1 );
|
||||||
mce.addRefEntity2(re2_2);
|
mce.addRefEntity2( re2_2 );
|
||||||
|
|
||||||
mce = em.merge(mce);
|
mce = em.merge( mce );
|
||||||
|
|
||||||
} finally {
|
|
||||||
tryCommit(tm);
|
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
// re1Id1 = re1_1.getId();
|
tryCommit( tm );
|
||||||
// re1Id2 = re1_2.getId();
|
}
|
||||||
// re2Id1 = re2_1.getId();
|
for ( MultipleCollectionRefEntity1 refEnt1 : mce.getRefEntities1() ) {
|
||||||
// re2Id2 = re2_2.getId();
|
if ( refEnt1.equals( re1_1 ) ) {
|
||||||
|
|
||||||
for (MultipleCollectionRefEntity1 refEnt1 : mce.getRefEntities1()) {
|
|
||||||
if (refEnt1.equals(re1_1)) {
|
|
||||||
re1Id1 = refEnt1.getId();
|
re1Id1 = refEnt1.getId();
|
||||||
} else if (refEnt1.equals(re1_2)) {
|
}
|
||||||
|
else if ( refEnt1.equals( re1_2 ) ) {
|
||||||
re1Id2 = refEnt1.getId();
|
re1Id2 = refEnt1.getId();
|
||||||
} else {
|
}
|
||||||
throw new IllegalStateException("unexpected instance");
|
else {
|
||||||
|
throw new IllegalStateException( "unexpected instance" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for ( MultipleCollectionRefEntity2 refEnt2 : mce.getRefEntities2() ) {
|
||||||
for (MultipleCollectionRefEntity2 refEnt2 : mce.getRefEntities2()) {
|
if ( refEnt2.equals( re2_1 ) ) {
|
||||||
if (refEnt2.equals(re2_1)) {
|
|
||||||
re2Id1 = refEnt2.getId();
|
re2Id1 = refEnt2.getId();
|
||||||
} else if (refEnt2.equals(re2_2)) {
|
}
|
||||||
|
else if ( refEnt2.equals( re2_2 ) ) {
|
||||||
re2Id2 = refEnt2.getId();
|
re2Id2 = refEnt2.getId();
|
||||||
} else {
|
}
|
||||||
throw new IllegalStateException("unexpected instance");
|
else {
|
||||||
|
throw new IllegalStateException( "unexpected instance" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
assertNotNull( re1Id1 );
|
||||||
assertNotNull(re1Id1);
|
assertNotNull( re1Id2 );
|
||||||
assertNotNull(re1Id2);
|
assertNotNull( re2Id1 );
|
||||||
assertNotNull(re2Id1);
|
assertNotNull( re2Id2 );
|
||||||
assertNotNull(re2Id2);
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
tm.begin();
|
tm.begin();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
newEntityManager();
|
em = createIsolatedEntityManager();
|
||||||
em = getEntityManager();
|
|
||||||
em.joinTransaction();
|
em.joinTransaction();
|
||||||
|
|
||||||
// mce = em.find(MultipleCollectionEntity.class, mceId1);
|
assertEquals( 2, mce.getRefEntities1().size() );
|
||||||
// mce = em.merge(mce);
|
|
||||||
|
|
||||||
assertEquals(2, mce.getRefEntities1().size());
|
mce.removeRefEntity1( re1_2 );
|
||||||
|
assertEquals( 1, mce.getRefEntities1().size() );
|
||||||
|
|
||||||
mce.removeRefEntity1(re1_2);
|
updatedRe1_1 = mce.getRefEntities1().get( 0 );
|
||||||
assertEquals(1, mce.getRefEntities1().size());
|
assertEquals( re1_1, updatedRe1_1 );
|
||||||
|
updatedRe1_1.setText( "MultipleCollectionRefEntity1-1-updated" );
|
||||||
updatedRe1_1 = mce.getRefEntities1().get(0);
|
|
||||||
assertEquals(re1_1, updatedRe1_1);
|
|
||||||
updatedRe1_1.setText("MultipleCollectionRefEntity1-1-updated");
|
|
||||||
|
|
||||||
re1_3 = new MultipleCollectionRefEntity1();
|
re1_3 = new MultipleCollectionRefEntity1();
|
||||||
re1_3.setText("MultipleCollectionRefEntity1-3");
|
re1_3.setText( "MultipleCollectionRefEntity1-3" );
|
||||||
re1_3.setMultipleCollectionEntity(mce);
|
re1_3.setMultipleCollectionEntity( mce );
|
||||||
mce.addRefEntity1(re1_3);
|
mce.addRefEntity1( re1_3 );
|
||||||
assertEquals(2, mce.getRefEntities1().size());
|
assertEquals( 2, mce.getRefEntities1().size() );
|
||||||
|
|
||||||
// -------------
|
assertEquals( 2, mce.getRefEntities2().size() );
|
||||||
|
|
||||||
assertEquals(2, mce.getRefEntities2().size());
|
mce.removeRefEntity2( re2_2 );
|
||||||
|
assertEquals( 1, mce.getRefEntities2().size() );
|
||||||
|
|
||||||
mce.removeRefEntity2(re2_2);
|
updatedRe2_1 = mce.getRefEntities2().get( 0 );
|
||||||
assertEquals(1, mce.getRefEntities2().size());
|
assertEquals( re2_1, updatedRe2_1 );
|
||||||
|
updatedRe2_1.setText( "MultipleCollectionRefEntity2-1-updated" );
|
||||||
updatedRe2_1 = mce.getRefEntities2().get(0);
|
|
||||||
assertEquals(re2_1, updatedRe2_1);
|
|
||||||
updatedRe2_1.setText("MultipleCollectionRefEntity2-1-updated");
|
|
||||||
|
|
||||||
re2_3 = new MultipleCollectionRefEntity2();
|
re2_3 = new MultipleCollectionRefEntity2();
|
||||||
re2_3.setText("MultipleCollectionRefEntity2-3");
|
re2_3.setText( "MultipleCollectionRefEntity2-3" );
|
||||||
re2_3.setMultipleCollectionEntity(mce);
|
re2_3.setMultipleCollectionEntity( mce );
|
||||||
mce.addRefEntity2(re2_3);
|
mce.addRefEntity2( re2_3 );
|
||||||
assertEquals(2, mce.getRefEntities2().size());
|
assertEquals( 2, mce.getRefEntities2().size() );
|
||||||
|
|
||||||
mce = em.merge(mce);
|
mce = em.merge( mce );
|
||||||
|
|
||||||
} finally {
|
|
||||||
tryCommit(tm);
|
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
// re1Id3 = re1_3.getId();
|
tryCommit( tm );
|
||||||
// re2Id3 = re2_3.getId();
|
}
|
||||||
|
for ( MultipleCollectionRefEntity1 adres : mce.getRefEntities1() ) {
|
||||||
for (MultipleCollectionRefEntity1 adres : mce.getRefEntities1()) {
|
if ( adres.equals( re1_3 ) ) {
|
||||||
if (adres.equals(re1_3)) {
|
|
||||||
re1Id3 = adres.getId();
|
re1Id3 = adres.getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for ( MultipleCollectionRefEntity2 partner : mce.getRefEntities2() ) {
|
||||||
for (MultipleCollectionRefEntity2 partner : mce.getRefEntities2()) {
|
if ( partner.equals( re2_3 ) ) {
|
||||||
if (partner.equals(re2_3)) {
|
|
||||||
re2Id3 = partner.getId();
|
re2Id3 = partner.getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
assertNotNull( re1Id3 );
|
||||||
assertNotNull(re1Id3);
|
assertNotNull( re2Id3 );
|
||||||
assertNotNull(re2Id3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRevisionsCounts() throws Exception {
|
public void testRevisionsCounts() throws Exception {
|
||||||
|
List<Number> mceId1Revs = getAuditReader().getRevisions( MultipleCollectionEntity.class, mceId1 );
|
||||||
|
List<Number> re1Id1Revs = getAuditReader().getRevisions( MultipleCollectionRefEntity1.class, re1Id1 );
|
||||||
|
List<Number> re1Id2Revs = getAuditReader().getRevisions( MultipleCollectionRefEntity1.class, re1Id2 );
|
||||||
|
List<Number> re1Id3Revs = getAuditReader().getRevisions( MultipleCollectionRefEntity1.class, re1Id3 );
|
||||||
|
List<Number> re2Id1Revs = getAuditReader().getRevisions( MultipleCollectionRefEntity2.class, re2Id1 );
|
||||||
|
List<Number> re2Id2Revs = getAuditReader().getRevisions( MultipleCollectionRefEntity2.class, re2Id2 );
|
||||||
|
List<Number> re2Id3Revs = getAuditReader().getRevisions( MultipleCollectionRefEntity2.class, re2Id3 );
|
||||||
|
|
||||||
List<Number> mceId1Revs = getAuditReader().getRevisions(
|
assertEquals( Arrays.asList( 1, 2, 3 ), mceId1Revs );
|
||||||
MultipleCollectionEntity.class, mceId1);
|
assertEquals( Arrays.asList( 2, 3 ), re1Id1Revs );
|
||||||
List<Number> re1Id1Revs = getAuditReader().getRevisions(
|
assertEquals( Arrays.asList( 2, 3 ), re1Id2Revs );
|
||||||
MultipleCollectionRefEntity1.class, re1Id1);
|
assertEquals( Arrays.asList( 3 ), re1Id3Revs );
|
||||||
List<Number> re1Id2Revs = getAuditReader().getRevisions(
|
assertEquals( Arrays.asList( 2, 3 ), re2Id1Revs );
|
||||||
MultipleCollectionRefEntity1.class, re1Id2);
|
assertEquals( Arrays.asList( 2, 3 ), re2Id2Revs );
|
||||||
List<Number> re1Id3Revs = getAuditReader().getRevisions(
|
assertEquals( Arrays.asList( 3 ), re2Id3Revs );
|
||||||
MultipleCollectionRefEntity1.class, re1Id3);
|
|
||||||
List<Number> re2Id1Revs = getAuditReader().getRevisions(
|
|
||||||
MultipleCollectionRefEntity2.class, re2Id1);
|
|
||||||
List<Number> re2Id2Revs = getAuditReader().getRevisions(
|
|
||||||
MultipleCollectionRefEntity2.class, re2Id2);
|
|
||||||
List<Number> re2Id3Revs = getAuditReader().getRevisions(
|
|
||||||
MultipleCollectionRefEntity2.class, re2Id3);
|
|
||||||
|
|
||||||
assertEquals(Arrays.asList(1, 2, 3), mceId1Revs);
|
|
||||||
assertEquals(Arrays.asList(2, 3), re1Id1Revs);
|
|
||||||
assertEquals(Arrays.asList(2, 3), re1Id2Revs);
|
|
||||||
assertEquals(Arrays.asList(3), re1Id3Revs);
|
|
||||||
assertEquals(Arrays.asList(2, 3), re2Id1Revs);
|
|
||||||
assertEquals(Arrays.asList(2, 3), re2Id2Revs);
|
|
||||||
assertEquals(Arrays.asList(3), re2Id3Revs);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -258,93 +220,92 @@ public class DetachedMultipleCollectionChangeTest extends AbstractEntityTest {
|
||||||
"MCE_RE1_AUD", "MCE_ID",
|
"MCE_RE1_AUD", "MCE_ID",
|
||||||
"aud.originalId.MultipleCollectionEntity_id", "RE1_ID",
|
"aud.originalId.MultipleCollectionEntity_id", "RE1_ID",
|
||||||
"aud.originalId.refEntities1_id", "aud.originalId.REV",
|
"aud.originalId.refEntities1_id", "aud.originalId.REV",
|
||||||
"aud.originalId.REV.id", "aud.REVTYPE");
|
"aud.originalId.REV.id", "aud.REVTYPE"
|
||||||
|
);
|
||||||
List<AuditJoinTableInfo> mceRe2AuditJoinTableInfos = getAuditJoinTableRows(
|
List<AuditJoinTableInfo> mceRe2AuditJoinTableInfos = getAuditJoinTableRows(
|
||||||
"MCE_RE2_AUD", "MCE_ID",
|
"MCE_RE2_AUD", "MCE_ID",
|
||||||
"aud.originalId.MultipleCollectionEntity_id", "RE2_ID",
|
"aud.originalId.MultipleCollectionEntity_id", "RE2_ID",
|
||||||
"aud.originalId.refEntities2_id", "aud.originalId.REV",
|
"aud.originalId.refEntities2_id", "aud.originalId.REV",
|
||||||
"aud.originalId.REV.id", "aud.REVTYPE");
|
"aud.originalId.REV.id", "aud.REVTYPE"
|
||||||
|
);
|
||||||
|
|
||||||
assertEquals(4, mceRe1AuditJoinTableInfos.size());
|
assertEquals( 4, mceRe1AuditJoinTableInfos.size() );
|
||||||
assertEquals(4, mceRe2AuditJoinTableInfos.size());
|
assertEquals( 4, mceRe2AuditJoinTableInfos.size() );
|
||||||
|
|
||||||
DefaultRevisionEntity rev2 = new DefaultRevisionEntity();
|
SequenceIdRevisionEntity rev2 = new SequenceIdRevisionEntity();
|
||||||
rev2.setId(2);
|
rev2.setId( 2 );
|
||||||
DefaultRevisionEntity rev3 = new DefaultRevisionEntity();
|
SequenceIdRevisionEntity rev3 = new SequenceIdRevisionEntity();
|
||||||
rev3.setId(3);
|
rev3.setId( 3 );
|
||||||
|
|
||||||
assertEquals(new AuditJoinTableInfo("MCE_RE1_AUD", rev2,
|
assertEquals(
|
||||||
RevisionType.ADD, "MCE_ID", 1L, "RE1_ID", 1L),
|
new AuditJoinTableInfo( "MCE_RE1_AUD", rev2, RevisionType.ADD, "MCE_ID", 1L, "RE1_ID", 1L ),
|
||||||
mceRe1AuditJoinTableInfos.get(0));
|
mceRe1AuditJoinTableInfos.get( 0 )
|
||||||
assertEquals(new AuditJoinTableInfo("MCE_RE1_AUD", rev2,
|
);
|
||||||
RevisionType.ADD, "MCE_ID", 1L, "RE1_ID", 2L),
|
assertEquals(
|
||||||
mceRe1AuditJoinTableInfos.get(1));
|
new AuditJoinTableInfo( "MCE_RE1_AUD", rev2, RevisionType.ADD, "MCE_ID", 1L, "RE1_ID", 2L ),
|
||||||
assertEquals(new AuditJoinTableInfo("MCE_RE1_AUD", rev3,
|
mceRe1AuditJoinTableInfos.get( 1 )
|
||||||
RevisionType.DEL, "MCE_ID", 1L, "RE1_ID", 2L),
|
);
|
||||||
mceRe1AuditJoinTableInfos.get(2));
|
assertEquals(
|
||||||
assertEquals(new AuditJoinTableInfo("MCE_RE1_AUD", rev3,
|
new AuditJoinTableInfo( "MCE_RE1_AUD", rev3, RevisionType.DEL, "MCE_ID", 1L, "RE1_ID", 2L ),
|
||||||
RevisionType.ADD, "MCE_ID", 1L, "RE1_ID", 3L),
|
mceRe1AuditJoinTableInfos.get( 2 )
|
||||||
mceRe1AuditJoinTableInfos.get(3));
|
);
|
||||||
|
assertEquals(
|
||||||
assertEquals(new AuditJoinTableInfo("MCE_RE2_AUD", rev2,
|
new AuditJoinTableInfo( "MCE_RE1_AUD", rev3, RevisionType.ADD, "MCE_ID", 1L, "RE1_ID", 3L ),
|
||||||
RevisionType.ADD, "MCE_ID", 1L, "RE2_ID", 1L),
|
mceRe1AuditJoinTableInfos.get( 3 )
|
||||||
mceRe2AuditJoinTableInfos.get(0));
|
);
|
||||||
assertEquals(new AuditJoinTableInfo("MCE_RE2_AUD", rev2,
|
|
||||||
RevisionType.ADD, "MCE_ID", 1L, "RE2_ID", 2L),
|
|
||||||
mceRe2AuditJoinTableInfos.get(1));
|
|
||||||
assertEquals(new AuditJoinTableInfo("MCE_RE2_AUD", rev3,
|
|
||||||
RevisionType.DEL, "MCE_ID", 1L, "RE2_ID", 2L),
|
|
||||||
mceRe2AuditJoinTableInfos.get(2));
|
|
||||||
assertEquals(new AuditJoinTableInfo("MCE_RE2_AUD", rev3,
|
|
||||||
RevisionType.ADD, "MCE_ID", 1L, "RE2_ID", 3L),
|
|
||||||
mceRe2AuditJoinTableInfos.get(3));
|
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
new AuditJoinTableInfo( "MCE_RE2_AUD", rev2, RevisionType.ADD, "MCE_ID", 1L, "RE2_ID", 1L ),
|
||||||
|
mceRe2AuditJoinTableInfos.get( 0 )
|
||||||
|
);
|
||||||
|
assertEquals(
|
||||||
|
new AuditJoinTableInfo( "MCE_RE2_AUD", rev2, RevisionType.ADD, "MCE_ID", 1L, "RE2_ID", 2L ),
|
||||||
|
mceRe2AuditJoinTableInfos.get( 1 )
|
||||||
|
);
|
||||||
|
assertEquals(
|
||||||
|
new AuditJoinTableInfo( "MCE_RE2_AUD", rev3, RevisionType.DEL, "MCE_ID", 1L, "RE2_ID", 2L ),
|
||||||
|
mceRe2AuditJoinTableInfos.get( 2 )
|
||||||
|
);
|
||||||
|
assertEquals(
|
||||||
|
new AuditJoinTableInfo( "MCE_RE2_AUD", rev3, RevisionType.ADD, "MCE_ID", 1L, "RE2_ID", 3L ),
|
||||||
|
mceRe2AuditJoinTableInfos.get( 3 )
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<AuditJoinTableInfo> getAuditJoinTableRows(
|
private List<AuditJoinTableInfo> getAuditJoinTableRows(String middleEntityName, String joinColumnIdName,
|
||||||
String middleEntityName, String joinColumnIdName,
|
String joinColumnIdProp, String inverseJoinColumnIdName,
|
||||||
String joinColumnIdProp, String inverseJoinColumnIdName,
|
String inverseJoinColumnIdProp, String revProp, String revIdProp,
|
||||||
String inverseJoinColumnIdProp, String revProp, String revIdProp,
|
String revTypeProp) throws Exception {
|
||||||
String revTypeProp) throws Exception {
|
StringBuilder qryBuilder = new StringBuilder( "select " );
|
||||||
|
qryBuilder.append( "aud " );
|
||||||
StringBuilder qryBuilder = new StringBuilder("select ");
|
qryBuilder.append( ", " ).append( joinColumnIdProp ).append( " as joinColumnId" );
|
||||||
qryBuilder.append("aud ");
|
qryBuilder.append( ", " ).append( inverseJoinColumnIdProp ).append( " as inverseJoinColumnId" );
|
||||||
qryBuilder.append(", ").append(joinColumnIdProp)
|
qryBuilder.append( ", " ).append( revProp ).append( " as rev" );
|
||||||
.append(" as joinColumnId");
|
qryBuilder.append( ", " ).append( revIdProp ).append( " as revId" );
|
||||||
qryBuilder.append(", ").append(inverseJoinColumnIdProp)
|
qryBuilder.append( ", " ).append( revTypeProp ).append( " as revType" );
|
||||||
.append(" as inverseJoinColumnId");
|
qryBuilder.append( " from " ).append( middleEntityName ).append( " aud " );
|
||||||
qryBuilder.append(", ").append(revProp).append(" as rev");
|
qryBuilder.append( " order by joinColumnId asc, inverseJoinColumnId asc, revId asc" );
|
||||||
qryBuilder.append(", ").append(revIdProp).append(" as revId");
|
|
||||||
qryBuilder.append(", ").append(revTypeProp).append(" as revType");
|
|
||||||
qryBuilder.append(" from ").append(middleEntityName).append(" aud ");
|
|
||||||
qryBuilder
|
|
||||||
.append(" order by joinColumnId asc, inverseJoinColumnId asc, revId asc");
|
|
||||||
|
|
||||||
String query = qryBuilder.toString();
|
String query = qryBuilder.toString();
|
||||||
|
|
||||||
newEntityManager();
|
EntityManager em = createIsolatedEntityManager();
|
||||||
EntityManager em = getEntityManager();
|
Query qry = em.createQuery( query );
|
||||||
Query qry = em.createQuery(query);
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<Object[]> auditJoinTableRows = qry.getResultList();
|
List<Object[]> auditJoinTableRows = qry.getResultList();
|
||||||
List<AuditJoinTableInfo> result = new ArrayList<AuditJoinTableInfo>(
|
List<AuditJoinTableInfo> result = new ArrayList<AuditJoinTableInfo>( auditJoinTableRows.size() );
|
||||||
auditJoinTableRows.size());
|
|
||||||
|
|
||||||
for (Object[] auditJoinTableRow : auditJoinTableRows) {
|
for ( Object[] auditJoinTableRow : auditJoinTableRows ) {
|
||||||
Long joinColumnId = (Long) auditJoinTableRow[1];
|
Long joinColumnId = (Long) auditJoinTableRow[1];
|
||||||
Long inverseJoinColumnId = (Long) auditJoinTableRow[2];
|
Long inverseJoinColumnId = (Long) auditJoinTableRow[2];
|
||||||
DefaultRevisionEntity rev = (DefaultRevisionEntity) auditJoinTableRow[3];
|
SequenceIdRevisionEntity rev = (SequenceIdRevisionEntity) auditJoinTableRow[3];
|
||||||
RevisionType revType = (RevisionType) auditJoinTableRow[5];
|
RevisionType revType = (RevisionType) auditJoinTableRow[5];
|
||||||
|
|
||||||
AuditJoinTableInfo info = new AuditJoinTableInfo(middleEntityName,
|
AuditJoinTableInfo info = new AuditJoinTableInfo(
|
||||||
rev, revType, joinColumnIdName, joinColumnId,
|
middleEntityName, rev, revType, joinColumnIdName, joinColumnId,
|
||||||
inverseJoinColumnIdName, inverseJoinColumnId);
|
inverseJoinColumnIdName, inverseJoinColumnId
|
||||||
result.add(info);
|
);
|
||||||
|
result.add( info );
|
||||||
LOG.error("Found: " + info);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -359,10 +320,9 @@ public class DetachedMultipleCollectionChangeTest extends AbstractEntityTest {
|
||||||
private final String inverseJoinColumnName;
|
private final String inverseJoinColumnName;
|
||||||
private final Long inverseJoinColumnId;
|
private final Long inverseJoinColumnId;
|
||||||
|
|
||||||
private AuditJoinTableInfo(String name, DefaultRevisionEntity rev,
|
private AuditJoinTableInfo(String name, SequenceIdRevisionEntity rev,
|
||||||
RevisionType revType, String joinColumnName, Long joinColumnId,
|
RevisionType revType, String joinColumnName, Long joinColumnId,
|
||||||
String inverseJoinColumnName, Long inverseJoinColumnId) {
|
String inverseJoinColumnName, Long inverseJoinColumnId) {
|
||||||
super();
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.revId = rev.getId();
|
this.revId = rev.getId();
|
||||||
this.revType = revType;
|
this.revType = revType;
|
||||||
|
@ -381,56 +341,52 @@ public class DetachedMultipleCollectionChangeTest extends AbstractEntityTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public boolean equals(Object o) {
|
||||||
final int prime = 31;
|
if ( this == o ) {
|
||||||
int result = 1;
|
|
||||||
result = prime
|
|
||||||
* result
|
|
||||||
+ ((inverseJoinColumnId == null) ? 0 : inverseJoinColumnId
|
|
||||||
.hashCode());
|
|
||||||
result = prime * result
|
|
||||||
+ ((joinColumnId == null) ? 0 : joinColumnId.hashCode());
|
|
||||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
|
||||||
result = prime * result + ((revId == null) ? 0 : revId.hashCode());
|
|
||||||
result = prime * result
|
|
||||||
+ ((revType == null) ? 0 : revType.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (this == obj)
|
|
||||||
return true;
|
return true;
|
||||||
if (obj == null)
|
}
|
||||||
|
if ( !( o instanceof AuditJoinTableInfo ) ) {
|
||||||
return false;
|
return false;
|
||||||
if (getClass() != obj.getClass())
|
}
|
||||||
|
|
||||||
|
AuditJoinTableInfo that = (AuditJoinTableInfo) o;
|
||||||
|
|
||||||
|
if ( inverseJoinColumnId != null ? !inverseJoinColumnId.equals( that.inverseJoinColumnId ) : that.inverseJoinColumnId != null ) {
|
||||||
return false;
|
return false;
|
||||||
AuditJoinTableInfo other = (AuditJoinTableInfo) obj;
|
}
|
||||||
if (inverseJoinColumnId == null) {
|
if ( joinColumnId != null ? !joinColumnId.equals( that.joinColumnId ) : that.joinColumnId != null ) {
|
||||||
if (other.inverseJoinColumnId != null)
|
|
||||||
return false;
|
|
||||||
} else if (!inverseJoinColumnId.equals(other.inverseJoinColumnId))
|
|
||||||
return false;
|
return false;
|
||||||
if (joinColumnId == null) {
|
}
|
||||||
if (other.joinColumnId != null)
|
if ( name != null ? !name.equals( that.name ) : that.name != null ) {
|
||||||
return false;
|
|
||||||
} else if (!joinColumnId.equals(other.joinColumnId))
|
|
||||||
return false;
|
return false;
|
||||||
if (name == null) {
|
}
|
||||||
if (other.name != null)
|
if ( revId != null ? !revId.equals( that.revId ) : that.revId != null ) {
|
||||||
return false;
|
|
||||||
} else if (!name.equals(other.name))
|
|
||||||
return false;
|
return false;
|
||||||
if (revId == null) {
|
}
|
||||||
if (other.revId != null)
|
if ( revType != that.revType ) {
|
||||||
return false;
|
|
||||||
} else if (!revId.equals(other.revId))
|
|
||||||
return false;
|
|
||||||
if (revType != other.revType)
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = name != null ? name.hashCode() : 0;
|
||||||
|
result = 31 * result + ( revId != null ? revId.hashCode() : 0 );
|
||||||
|
result = 31 * result + ( revType != null ? revType.hashCode() : 0 );
|
||||||
|
result = 31 * result + ( joinColumnId != null ? joinColumnId.hashCode() : 0 );
|
||||||
|
result = 31 * result + ( inverseJoinColumnId != null ? inverseJoinColumnId.hashCode() : 0 );
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void tryCommit(TransactionManager tm) throws Exception {
|
||||||
|
if ( tm.getStatus() == Status.STATUS_MARKED_ROLLBACK ) {
|
||||||
|
tm.rollback();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tm.commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue