HHH-7187 - Fixing tests on Oracle

This commit is contained in:
Lukasz Antoniak 2012-04-08 23:25:26 +02:00 committed by Strong Liu
parent 75d684149d
commit 775b6da1db
141 changed files with 952 additions and 315 deletions

View File

@ -27,6 +27,9 @@ import java.io.IOException;
import java.util.Properties;
import javax.persistence.EntityManager;
import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.envers.test.entities.reventity.OracleRevisionEntity;
import org.hibernate.envers.test.entities.reventity.trackmodifiedentities.OracleTrackingModifiedEntitiesRevisionEntity;
import org.junit.Before;
import org.hibernate.cfg.Environment;
@ -44,6 +47,7 @@ import org.hibernate.testing.BeforeClassOnce;
/**
* @author Adam Warski (adam at warski dot org)
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
*/
public abstract class AbstractEntityTest extends AbstractEnversTest {
public static final Dialect DIALECT = Dialect.getDialect();
@ -57,6 +61,16 @@ public abstract class AbstractEntityTest extends AbstractEnversTest {
public abstract void configure(Ejb3Configuration cfg);
protected void revisionEntityForDialect(Ejb3Configuration cfg, Dialect dialect, Properties configurationProperties) {
if (dialect instanceof Oracle8iDialect) {
if (Boolean.parseBoolean(configurationProperties.getProperty("org.hibernate.envers.track_entities_changed_in_revision"))) {
cfg.addAnnotatedClass(OracleTrackingModifiedEntitiesRevisionEntity.class);
} else {
cfg.addAnnotatedClass(OracleRevisionEntity.class);
}
}
}
public void addConfigurationProperties(Properties configuration) { }
protected static Dialect getDialect() {
@ -105,6 +119,7 @@ public abstract class AbstractEntityTest extends AbstractEnversTest {
cfg = new Ejb3Configuration();
configure(cfg);
revisionEntityForDialect(cfg, getDialect(), configurationProperties);
cfg.configure(configurationProperties);
emf = (EntityManagerFactoryImpl) cfg.buildEntityManagerFactory( createBootstrapRegistryBuilder() );
@ -113,6 +128,7 @@ public abstract class AbstractEntityTest extends AbstractEnversTest {
newEntityManager();
}
protected boolean createSchema() {
return true;
}
@ -121,7 +137,6 @@ public abstract class AbstractEntityTest extends AbstractEnversTest {
return new BootstrapServiceRegistryBuilder();
}
@AfterClassOnce
public void close() {
closeEntityManager();

View File

@ -2,6 +2,10 @@ package org.hibernate.envers.test;
import java.net.URISyntaxException;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.envers.test.entities.reventity.OracleRevisionEntity;
import org.hibernate.envers.test.entities.reventity.trackmodifiedentities.OracleTrackingModifiedEntitiesRevisionEntity;
import org.junit.Before;
import org.hibernate.MappingException;
@ -20,9 +24,10 @@ import org.hibernate.testing.ServiceRegistryBuilder;
* Base class for testing envers with Session.
*
* @author Hernán Chanfreau
*
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
*/
public abstract class AbstractSessionTest extends AbstractEnversTest {
public static final Dialect DIALECT = Dialect.getDialect();
protected Configuration config;
private ServiceRegistry serviceRegistry;
@ -30,6 +35,9 @@ public abstract class AbstractSessionTest extends AbstractEnversTest {
private Session session ;
private AuditReader auditReader;
protected static Dialect getDialect() {
return DIALECT;
}
@BeforeClassOnce
public void init() throws URISyntaxException {
@ -43,6 +51,7 @@ public abstract class AbstractSessionTest extends AbstractEnversTest {
}
this.initMappings();
revisionEntityForDialect(config, getDialect());
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( config.getProperties() );
sessionFactory = config.buildSessionFactory( serviceRegistry );
@ -52,6 +61,16 @@ public abstract class AbstractSessionTest extends AbstractEnversTest {
}
protected abstract void initMappings() throws MappingException, URISyntaxException ;
protected void revisionEntityForDialect(Configuration cfg, Dialect dialect) {
if (dialect instanceof Oracle8iDialect) {
if (Boolean.parseBoolean(config.getProperty("org.hibernate.envers.track_entities_changed_in_revision"))) {
cfg.addAnnotatedClass(OracleTrackingModifiedEntitiesRevisionEntity.class);
} else {
cfg.addAnnotatedClass(OracleRevisionEntity.class);
}
}
}
private SessionFactory getSessionFactory(){
return sessionFactory;
}

View File

@ -36,18 +36,18 @@ public class IntNoAutoIdTestEntity {
private Integer id;
@Audited
private Integer number;
private Integer numVal;
public IntNoAutoIdTestEntity() {
}
public IntNoAutoIdTestEntity(Integer number, Integer id) {
public IntNoAutoIdTestEntity(Integer numVal, Integer id) {
this.id = id;
this.number = number;
this.numVal = numVal;
}
public IntNoAutoIdTestEntity(Integer number) {
this.number = number;
public IntNoAutoIdTestEntity(Integer numVal) {
this.numVal = numVal;
}
public Integer getId() {
@ -58,12 +58,12 @@ public class IntNoAutoIdTestEntity {
this.id = id;
}
public Integer getNumber() {
return number;
public Integer getNumVal() {
return numVal;
}
public void setNumber(Integer number) {
this.number = number;
public void setNumVal(Integer numVal) {
this.numVal = numVal;
}
public boolean equals(Object o) {
@ -74,7 +74,7 @@ public class IntNoAutoIdTestEntity {
if (id != null ? !id.equals(that.id) : that.id != null) return false;
//noinspection RedundantIfStatement
if (number != null ? !number.equals(that.number) : that.number != null) return false;
if (numVal != null ? !numVal.equals(that.numVal) : that.numVal != null) return false;
return true;
}
@ -82,11 +82,11 @@ public class IntNoAutoIdTestEntity {
public int hashCode() {
int result;
result = (id != null ? id.hashCode() : 0);
result = 31 * result + (number != null ? number.hashCode() : 0);
result = 31 * result + (numVal != null ? numVal.hashCode() : 0);
return result;
}
public String toString() {
return "INATE(id = " + id + ", number = " + number + ")";
return "INATE(id = " + id + ", numVal = " + numVal + ")";
}
}

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.entities;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@ -38,6 +39,7 @@ public class IntTestEntity {
private Integer id;
@Audited
@Column(name = "NUMERIC_VALUE")
private Integer number;
public IntTestEntity() {
@ -81,8 +83,7 @@ public class IntTestEntity {
}
public int hashCode() {
int result;
result = (id != null ? id.hashCode() : 0);
int result = (id != null ? id.hashCode() : 0);
result = 31 * result + (number != null ? number.hashCode() : 0);
return result;
}

View File

@ -38,22 +38,22 @@ public class PrimitiveTestEntity {
private Integer id;
@Audited
private int number;
private int numVal1;
private int number2;
private int numVal2;
public PrimitiveTestEntity() {
}
public PrimitiveTestEntity(int number, int number2) {
this.number = number;
this.number2 = number2;
public PrimitiveTestEntity(int numVal1, int numVal2) {
this.numVal1 = numVal1;
this.numVal2 = numVal2;
}
public PrimitiveTestEntity(Integer id, int number, int number2) {
public PrimitiveTestEntity(Integer id, int numVal1, int number2) {
this.id = id;
this.number = number;
this.number2 = number2;
this.numVal1 = numVal1;
this.numVal2 = numVal2;
}
public Integer getId() {
@ -64,20 +64,20 @@ public class PrimitiveTestEntity {
this.id = id;
}
public Integer getNumber() {
return number;
public Integer getNumVal1() {
return numVal1;
}
public void setNumber(Integer number) {
this.number = number;
public void setNumVal1(Integer numVal1) {
this.numVal1 = numVal1;
}
public int getNumber2() {
return number2;
public int getNumVal2() {
return numVal2;
}
public void setNumber2(int number2) {
this.number2 = number2;
public void setNumVal2(int numVal2) {
this.numVal2 = numVal2;
}
@Override
@ -87,8 +87,8 @@ public class PrimitiveTestEntity {
PrimitiveTestEntity that = (PrimitiveTestEntity) o;
if (number != that.number) return false;
if (number2 != that.number2) return false;
if (numVal1 != that.numVal1) return false;
if (numVal2 != that.numVal2) return false;
if (id != null ? !id.equals(that.id) : that.id != null) return false;
return true;
@ -97,12 +97,12 @@ public class PrimitiveTestEntity {
@Override
public int hashCode() {
int result = id != null ? id.hashCode() : 0;
result = 31 * result + number;
result = 31 * result + number2;
result = 31 * result + numVal1;
result = 31 * result + numVal2;
return result;
}
public String toString() {
return "PTE(id = " + id + ", number = " + number + ", number2 = " + number2 + ")";
return "PTE(id = " + id + ", numVal1 = " + numVal1 + ", numVal2 = " + numVal2 + ")";
}
}

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.test.entities;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@ -41,6 +42,7 @@ public class StrIntTestEntity {
private String str1;
@Audited
@Column(name = "NUM_VAL")
private Integer number;
public StrIntTestEntity() {

View File

@ -25,6 +25,7 @@ package org.hibernate.envers.test.entities;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -32,6 +33,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "STR_TEST")
public class StrTestEntity {
@Id
@GeneratedValue

View File

@ -26,6 +26,7 @@ import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -33,6 +34,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "CompTest")
public class ComponentTestEntity {
@Id
@GeneratedValue
@ -108,4 +110,3 @@ public class ComponentTestEntity {
return "CTE(id = " + id + ", comp1 = " + comp1 + ", comp2 = " + comp2 + ")";
}
}

View File

@ -29,6 +29,7 @@ import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -36,6 +37,7 @@ import org.hibernate.envers.Audited;
* @author Erik-Berndt Scheper
*/
@Entity
@Table(name = "DefaultValueComponent")
@Audited
public class DefaultValueComponentTestEntity {
@Id

View File

@ -24,6 +24,7 @@
package org.hibernate.envers.test.entities.components.relations;
import javax.persistence.Embeddable;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.envers.test.entities.StrTestEntity;
@ -31,6 +32,7 @@ import org.hibernate.envers.test.entities.StrTestEntity;
* @author Adam Warski (adam at warski dot org)
*/
@Embeddable
@Table(name = "ManyToOneCompEmb")
public class ManyToOneComponent {
@ManyToOne
private StrTestEntity entity;

View File

@ -26,6 +26,7 @@ import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -33,6 +34,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "ManyToOneCompEnt")
public class ManyToOneComponentTestEntity {
@Id
@GeneratedValue

View File

@ -24,6 +24,7 @@
package org.hibernate.envers.test.entities.components.relations;
import javax.persistence.Embeddable;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.envers.NotAudited;
import org.hibernate.envers.test.entities.UnversionedStrTestEntity;
@ -32,6 +33,7 @@ import org.hibernate.envers.test.entities.UnversionedStrTestEntity;
* @author Adam Warski (adam at warski dot org)
*/
@Embeddable
@Table(name = "NotAudM2OCompEmb")
public class NotAuditedManyToOneComponent {
@ManyToOne
@NotAudited

View File

@ -26,6 +26,7 @@ import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -33,6 +34,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "NotAudM2OCompEnt")
public class NotAuditedManyToOneComponentTestEntity {
@Id
@GeneratedValue

View File

@ -26,6 +26,7 @@ import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -33,6 +34,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "OneToManyComp")
public class OneToManyComponentTestEntity {
@Id
@GeneratedValue

View File

@ -25,6 +25,7 @@ package org.hibernate.envers.test.entities.customtype;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
@ -37,6 +38,7 @@ import org.hibernate.envers.Audited;
@Entity
@TypeDef(name = "param", typeClass = ParametrizedTestUserType.class,
parameters = { @Parameter(name="param1", value = "x"), @Parameter(name="param2", value = "y") })
@Table(name = "ParamCustType")
public class ParametrizedCustomTypeEntity {
@Id
@GeneratedValue

View File

@ -24,6 +24,7 @@
package org.hibernate.envers.test.entities.ids;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -31,6 +32,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "EmbIdEnt")
public class EmbIdTestEntity {
@EmbeddedId
private EmbId id;

View File

@ -24,6 +24,7 @@
package org.hibernate.envers.test.entities.ids;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -31,6 +32,7 @@ import org.hibernate.envers.Audited;
* @author Slawek Garwol (slawekgarwol at gmail dot com)
*/
@Entity
@Table(name = "EmbIdWithCustType")
public class EmbIdWithCustomTypeTestEntity {
@EmbeddedId
private EmbIdWithCustomType id;

View File

@ -2,11 +2,13 @@ package org.hibernate.envers.test.entities.ids;
import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "ManyToOneIdNotAud")
public class ManyToOneIdNotAuditedTestEntity implements Serializable {
@EmbeddedId
private ManyToOneNotAuditedEmbId id;

View File

@ -25,6 +25,7 @@ package org.hibernate.envers.test.entities.ids;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -32,6 +33,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "MulId")
@IdClass(MulId.class)
public class MulIdTestEntity {
@Id

View File

@ -26,6 +26,7 @@ import java.util.List;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -34,6 +35,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "ListOwned")
public class ListOwnedEntity {
@Id
private Integer id;

View File

@ -26,6 +26,7 @@ import java.util.List;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -34,6 +35,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "ListOwning")
public class ListOwningEntity {
@Id
private Integer id;

View File

@ -26,6 +26,7 @@ import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -34,6 +35,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "MapOwned")
public class MapOwnedEntity {
@Id
private Integer id;

View File

@ -28,6 +28,7 @@ import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.MapKeyColumn;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -36,6 +37,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "MapOwning")
public class MapOwningEntity {
@Id
private Integer id;

View File

@ -26,6 +26,7 @@ import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -34,6 +35,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "SetOwned")
public class SetOwnedEntity {
@Id
private Integer id;

View File

@ -26,6 +26,7 @@ import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -34,6 +35,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "SetOwning")
public class SetOwningEntity {
@Id
private Integer id;

View File

@ -27,6 +27,7 @@ import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
import org.hibernate.envers.RelationTargetAuditMode;
@ -38,6 +39,7 @@ import org.hibernate.envers.test.entities.UnversionedStrTestEntity;
* @author Adam Warski
*/
@Entity
@Table(name = "M2MTargetNotAud")
public class M2MTargetNotAuditedEntity {
@Id
private Integer id;

View File

@ -4,6 +4,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -13,6 +14,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "DoubleJoinColBiRefEd1")
@Audited
public class DoubleListJoinColumnBidirectionalRefEdEntity1 {
@Id

View File

@ -4,6 +4,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -13,6 +14,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "DoubleJoinColBiRefEd2")
@Audited
public class DoubleListJoinColumnBidirectionalRefEdEntity2 {
@Id

View File

@ -6,6 +6,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.envers.AuditMappedBy;
import org.hibernate.envers.Audited;
@ -16,6 +17,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "DoubleJoinColBiRefIng")
@Audited
public class DoubleListJoinColumnBidirectionalRefIngEntity {
@Id

View File

@ -5,6 +5,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -14,6 +15,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "IdxListJoinColBiRefEd")
@Audited
public class IndexedListJoinColumnBidirectionalRefEdEntity {
@Id

View File

@ -7,6 +7,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.IndexColumn;
import org.hibernate.envers.AuditMappedBy;
@ -18,6 +19,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "IdxListJoinColBiRefIng")
@Audited
public class IndexedListJoinColumnBidirectionalRefIngEntity {
@Id

View File

@ -1,6 +1,7 @@
package org.hibernate.envers.test.entities.onetomany.detached;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -10,6 +11,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "ListJoinColBiInhRefEdChild")
@DiscriminatorValue("2")
@Audited
public class ListJoinColumnBidirectionalInheritanceRefEdChildEntity extends ListJoinColumnBidirectionalInheritanceRefEdParentEntity {

View File

@ -9,6 +9,7 @@ import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -18,6 +19,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "ListJoinColBiInhRefEdPar")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "discriminator", discriminatorType = DiscriminatorType.INTEGER)
@DiscriminatorValue("1")

View File

@ -7,6 +7,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.envers.AuditMappedBy;
import org.hibernate.envers.Audited;
@ -17,6 +18,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "ListJoinColBiInhRefIng")
@Audited
public class ListJoinColumnBidirectionalInheritanceRefIngEntity {
@Id

View File

@ -4,6 +4,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -13,6 +14,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "ListJoinColBiRefEd")
@Audited
public class ListJoinColumnBidirectionalRefEdEntity {
@Id

View File

@ -7,6 +7,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.envers.AuditMappedBy;
import org.hibernate.envers.Audited;
@ -17,6 +18,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "ListJoinColBiRefIng")
@Audited
public class ListJoinColumnBidirectionalRefIngEntity {
@Id

View File

@ -27,7 +27,9 @@ import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.envers.AuditJoinTable;
import org.hibernate.envers.Audited;
import org.hibernate.envers.test.entities.StrTestEntity;
@ -36,6 +38,7 @@ import org.hibernate.envers.test.entities.StrTestEntity;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "SetJoinColRefColl")
public class SetJoinColumnRefCollEntity {
@Id
private Integer id;
@ -46,6 +49,7 @@ public class SetJoinColumnRefCollEntity {
@Audited
@OneToMany
@JoinColumn(name = "SJCR_ID")
@AuditJoinTable(name = "SetJoinColRefColl_StrTest_AUD")
private Set<StrTestEntity> collection;
public SetJoinColumnRefCollEntity() {

View File

@ -26,6 +26,7 @@ import java.util.Set;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
import org.hibernate.envers.test.entities.ids.EmbId;
@ -36,6 +37,7 @@ import org.hibernate.envers.test.entities.ids.EmbIdTestEntity;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "SetRefCollEmbId")
public class SetRefCollEntityEmbId {
@EmbeddedId
private EmbId id;

View File

@ -27,6 +27,7 @@ import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
import org.hibernate.envers.test.entities.ids.MulId;
@ -37,6 +38,7 @@ import org.hibernate.envers.test.entities.ids.MulIdTestEntity;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "SetRefCollMulId")
@IdClass(MulId.class)
public class SetRefCollEntityMulId {
@Id

View File

@ -1,5 +1,6 @@
package org.hibernate.envers.test.entities.onetomany.detached.inheritance;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -9,6 +10,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "ChildIdxJoinColBiRefIng")
@Audited
public class ChildIndexedListJoinColumnBidirectionalRefIngEntity extends ParentIndexedListJoinColumnBidirectionalRefIngEntity {
private String data2;

View File

@ -9,6 +9,7 @@ import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.IndexColumn;
import org.hibernate.envers.AuditMappedBy;
@ -21,6 +22,7 @@ import org.hibernate.envers.Audited;
*/
@Entity
@Audited
@Table(name = "ParentIdxJoinColBiRefIng")
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class ParentIndexedListJoinColumnBidirectionalRefIngEntity {
@Id

View File

@ -5,6 +5,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -14,6 +15,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "ParOwnedIdxJoinColBiRefEd")
@Audited
public class ParentOwnedIndexedListJoinColumnBidirectionalRefEdEntity {
@Id

View File

@ -0,0 +1,68 @@
package org.hibernate.envers.test.entities.reventity;
import org.hibernate.envers.RevisionNumber;
import org.hibernate.envers.RevisionTimestamp;
import javax.persistence.*;
import java.io.Serializable;
import java.text.DateFormat;
import java.util.Date;
/**
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
*/
@MappedSuperclass
public abstract class AbstractOracleRevisionEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "RevisionNumberSequenceGenerator")
@SequenceGenerator(name = "RevisionNumberSequenceGenerator", sequenceName="REVISION_SEQ",
allocationSize = 1, initialValue = 1)
@RevisionNumber
private int id;
@RevisionTimestamp
private long timestamp;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Transient
public Date getRevisionDate() {
return new Date(timestamp);
}
public long getTimestamp() {
return timestamp;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof AbstractOracleRevisionEntity)) return false;
AbstractOracleRevisionEntity that = (AbstractOracleRevisionEntity) o;
if (id != that.id) return false;
if (timestamp != that.timestamp) return false;
return true;
}
public int hashCode() {
int result = id;
result = 31 * result + (int) (timestamp ^ (timestamp >>> 32));
return result;
}
public String toString() {
return "AbstractOracleRevisionEntity(id = " + id + ", revisionDate = " + DateFormat.getDateTimeInstance().format(getRevisionDate()) + ")";
}
}

View File

@ -26,6 +26,8 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.envers.RevisionEntity;
import org.hibernate.envers.RevisionNumber;
import org.hibernate.envers.RevisionTimestamp;
@ -34,10 +36,18 @@ import org.hibernate.envers.RevisionTimestamp;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@GenericGenerator(name = "EnversTestingRevisionGenerator",
strategy = "org.hibernate.id.enhanced.TableGenerator",
parameters = {@Parameter(name = "table_name", value = "REVISION_GENERATOR"),
@Parameter(name = "initial_value", value = "1"),
@Parameter(name = "increment_size", value = "1"),
@Parameter(name = "prefer_entity_table_as_segment_value", value = "true")
}
)
@RevisionEntity
public class CustomDataRevEntity {
@Id
@GeneratedValue
@GeneratedValue(generator = "EnversTestingRevisionGenerator")
@RevisionNumber
private int customId;

View File

@ -27,6 +27,8 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.envers.RevisionEntity;
import org.hibernate.envers.RevisionNumber;
import org.hibernate.envers.RevisionTimestamp;
@ -35,10 +37,18 @@ import org.hibernate.envers.RevisionTimestamp;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@GenericGenerator(name = "EnversTestingRevisionGenerator",
strategy = "org.hibernate.id.enhanced.TableGenerator",
parameters = {@Parameter(name = "table_name", value = "REVISION_GENERATOR"),
@Parameter(name = "initial_value", value = "1"),
@Parameter(name = "increment_size", value = "1"),
@Parameter(name = "prefer_entity_table_as_segment_value", value = "true")
}
)
@RevisionEntity
public class CustomDateRevEntity {
@Id
@GeneratedValue
@GeneratedValue(generator = "EnversTestingRevisionGenerator")
@RevisionNumber
private int customId;

View File

@ -26,6 +26,8 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.envers.RevisionEntity;
import org.hibernate.envers.RevisionNumber;
import org.hibernate.envers.RevisionTimestamp;
@ -34,6 +36,14 @@ import org.hibernate.envers.RevisionTimestamp;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@GenericGenerator(name = "EnversTestingRevisionGenerator",
strategy = "org.hibernate.id.enhanced.TableGenerator",
parameters = {@Parameter(name = "table_name", value = "REVISION_GENERATOR"),
@Parameter(name = "initial_value", value = "1"),
@Parameter(name = "increment_size", value = "1"),
@Parameter(name = "prefer_entity_table_as_segment_value", value = "true")
}
)
@RevisionEntity
public class CustomPropertyAccessRevEntity {
private int customId;
@ -41,7 +51,7 @@ public class CustomPropertyAccessRevEntity {
private long customTimestamp;
@Id
@GeneratedValue
@GeneratedValue(generator = "EnversTestingRevisionGenerator")
@RevisionNumber
public int getCustomId() {
return customId;

View File

@ -26,6 +26,8 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.envers.RevisionEntity;
import org.hibernate.envers.RevisionNumber;
import org.hibernate.envers.RevisionTimestamp;
@ -34,10 +36,18 @@ import org.hibernate.envers.RevisionTimestamp;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@GenericGenerator(name = "EnversTestingRevisionGenerator",
strategy = "org.hibernate.id.enhanced.TableGenerator",
parameters = {@Parameter(name = "table_name", value = "REVISION_GENERATOR"),
@Parameter(name = "initial_value", value = "1"),
@Parameter(name = "increment_size", value = "1"),
@Parameter(name = "prefer_entity_table_as_segment_value", value = "true")
}
)
@RevisionEntity
public class CustomRevEntity {
@Id
@GeneratedValue
@GeneratedValue(generator = "EnversTestingRevisionGenerator")
@RevisionNumber
private int customId;

View File

@ -27,6 +27,8 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.envers.RevisionEntity;
import org.hibernate.envers.RevisionNumber;
import org.hibernate.envers.RevisionTimestamp;
@ -35,10 +37,18 @@ import org.hibernate.envers.RevisionTimestamp;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@GenericGenerator(name = "EnversTestingRevisionGenerator",
strategy = "org.hibernate.id.enhanced.TableGenerator",
parameters = {@Parameter(name = "table_name", value = "REVISION_GENERATOR"),
@Parameter(name = "initial_value", value = "1"),
@Parameter(name = "increment_size", value = "1"),
@Parameter(name = "prefer_entity_table_as_segment_value", value = "true")
}
)
@RevisionEntity
public class CustomRevEntityColumnMapping {
@Id
@GeneratedValue
@GeneratedValue(generator = "EnversTestingRevisionGenerator")
@Column(columnDefinition = "int")
@RevisionNumber
private Long customId;

View File

@ -0,0 +1,21 @@
package org.hibernate.envers.test.entities.reventity;
import org.hibernate.envers.RevisionEntity;
import org.hibernate.envers.RevisionNumber;
import org.hibernate.envers.RevisionTimestamp;
import javax.persistence.*;
import java.io.Serializable;
import java.text.DateFormat;
import java.util.Date;
/**
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
*/
@Entity
@RevisionEntity
public class OracleRevisionEntity extends AbstractOracleRevisionEntity {
public String toString() {
return "OracleRevisionEntity(" + super.toString() + ")";
}
}

View File

@ -0,0 +1,54 @@
package org.hibernate.envers.test.entities.reventity.trackmodifiedentities;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.envers.ModifiedEntityNames;
import org.hibernate.envers.test.entities.reventity.AbstractOracleRevisionEntity;
import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;
/**
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
*/
@MappedSuperclass
public abstract class AbstractOracleTrackingModifiedEntitiesRevisionEntity extends AbstractOracleRevisionEntity {
@ElementCollection(fetch = FetchType.EAGER)
@JoinTable(name = "REVCHANGES", joinColumns = @JoinColumn(name = "REV"))
@Column(name = "ENTITYNAME")
@Fetch(FetchMode.JOIN)
@ModifiedEntityNames
private Set<String> modifiedEntityNames = new HashSet<String>();
public Set<String> getModifiedEntityNames() {
return modifiedEntityNames;
}
public void setModifiedEntityNames(Set<String> modifiedEntityNames) {
this.modifiedEntityNames = modifiedEntityNames;
}
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof AbstractOracleTrackingModifiedEntitiesRevisionEntity)) return false;
if (!super.equals(o)) return false;
AbstractOracleTrackingModifiedEntitiesRevisionEntity that = (AbstractOracleTrackingModifiedEntitiesRevisionEntity) o;
if (modifiedEntityNames != null ? !modifiedEntityNames.equals(that.modifiedEntityNames)
: that.modifiedEntityNames != null) return false;
return true;
}
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (modifiedEntityNames != null ? modifiedEntityNames.hashCode() : 0);
return result;
}
public String toString() {
return "AbstractOracleTrackingModifiedEntitiesRevisionEntity(" + super.toString() + ", modifiedEntityNames = " + modifiedEntityNames + ")";
}
}

View File

@ -8,7 +8,10 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.envers.ModifiedEntityNames;
import org.hibernate.envers.RevisionEntity;
import org.hibernate.envers.RevisionNumber;
@ -19,10 +22,19 @@ import org.hibernate.envers.RevisionTimestamp;
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
*/
@Entity
@Table(name = "AnnotatedTrackRevInfo")
@GenericGenerator(name = "EnversTestingRevisionGenerator",
strategy = "org.hibernate.id.enhanced.TableGenerator",
parameters = {@Parameter(name = "table_name", value = "REVISION_GENERATOR"),
@Parameter(name = "initial_value", value = "1"),
@Parameter(name = "increment_size", value = "1"),
@Parameter(name = "prefer_entity_table_as_segment_value", value = "true")
}
)
@RevisionEntity
public class AnnotatedTrackingRevisionEntity {
@Id
@GeneratedValue
@GeneratedValue(generator = "EnversTestingRevisionGenerator")
@RevisionNumber
private int customId;

View File

@ -7,7 +7,10 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.envers.RevisionEntity;
import org.hibernate.envers.RevisionNumber;
import org.hibernate.envers.RevisionTimestamp;
@ -17,10 +20,19 @@ import org.hibernate.envers.RevisionTimestamp;
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
*/
@Entity
@Table(name = "CustomTrackRevInfo")
@GenericGenerator(name = "EnversTestingRevisionGenerator",
strategy = "org.hibernate.id.enhanced.TableGenerator",
parameters = {@Parameter(name = "table_name", value = "REVISION_GENERATOR"),
@Parameter(name = "initial_value", value = "1"),
@Parameter(name = "increment_size", value = "1"),
@Parameter(name = "prefer_entity_table_as_segment_value", value = "true")
}
)
@RevisionEntity(CustomTrackingRevisionListener.class)
public class CustomTrackingRevisionEntity {
@Id
@GeneratedValue
@GeneratedValue(generator = "EnversTestingRevisionGenerator")
@RevisionNumber
private int customId;

View File

@ -0,0 +1,22 @@
package org.hibernate.envers.test.entities.reventity.trackmodifiedentities;
import org.hibernate.envers.RevisionEntity;
import javax.persistence.Entity;
/**
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
*/
@Entity
@RevisionEntity(OracleExtendedRevisionListener.class)
public class OracleExtendedRevisionEntity extends AbstractOracleTrackingModifiedEntitiesRevisionEntity {
private String userComment;
public String getUserComment() {
return userComment;
}
public void setUserComment(String userComment) {
this.userComment = userComment;
}
}

View File

@ -0,0 +1,14 @@
package org.hibernate.envers.test.entities.reventity.trackmodifiedentities;
import org.hibernate.envers.RevisionListener;
/**
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
*/
public class OracleExtendedRevisionListener implements RevisionListener {
public static final String COMMENT_VALUE = "User Comment";
public void newRevision(Object revisionEntity) {
((OracleExtendedRevisionEntity)revisionEntity).setUserComment(COMMENT_VALUE);
}
}

View File

@ -0,0 +1,23 @@
package org.hibernate.envers.test.entities.reventity.trackmodifiedentities;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.envers.ModifiedEntityNames;
import org.hibernate.envers.RevisionEntity;
import org.hibernate.envers.test.entities.reventity.AbstractOracleRevisionEntity;
import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;
/**
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
*/
@Entity
@Table(name = "TrackModifiedEntitiesRevInfo")
@RevisionEntity
public class OracleTrackingModifiedEntitiesRevisionEntity extends AbstractOracleTrackingModifiedEntitiesRevisionEntity {
public String toString() {
return "OracleTrackingModifiedEntitiesRevisionEntity(" + super.toString() + ")";
}
}

View File

@ -69,7 +69,7 @@ public class FieldAccessType extends AbstractEntityTest {
public void testHistoryOfId1() {
FieldAccessTypeEntity ver1 = new FieldAccessTypeEntity(id1, "data");
FieldAccessTypeEntity ver2 = new FieldAccessTypeEntity(id1, "data2");
Assert.assertEquals(getAuditReader().find(FieldAccessTypeEntity.class, id1, 1), ver1);
Assert.assertEquals(getAuditReader().find(FieldAccessTypeEntity.class, id1, 2), ver2);
Assert.assertEquals(ver1, getAuditReader().find(FieldAccessTypeEntity.class, id1, 1));
Assert.assertEquals(ver2, getAuditReader().find(FieldAccessTypeEntity.class, id1, 2));
}
}

View File

@ -44,7 +44,7 @@ public class ColumnScalePrecisionTest extends AbstractEntityTest {
@Test
public void testColumnScalePrecision() {
Column testColumn = new Column("number");
Column testColumn = new Column("wholeNumber");
Column scalePrecisionAuditColumn = auditTable.getColumn(testColumn);
Column scalePrecisionColumn = originalTable.getColumn(testColumn);

View File

@ -26,7 +26,9 @@ package org.hibernate.envers.test.integration.basic;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import org.hibernate.dialect.Dialect;
import org.junit.Assert;
import org.junit.Test;
@ -47,6 +49,11 @@ public class NoneAudited extends AbstractEntityTest {
// The AuditReader shouldn't be created
}
@Override
protected void revisionEntityForDialect(Ejb3Configuration cfg, Dialect dialect, Properties configurationProperties) {
// Do not add any dialect-specific Envers configuration.
}
@Test
public void testRevisionInfoTableNotCreated() {
@SuppressWarnings({"unchecked"}) List<PersistentClass> pcs = iteratorToList(getCfg().getClassMappings());

View File

@ -19,18 +19,18 @@ public class ScalePrecisionEntity implements Serializable {
private Long id;
@Column(precision = 3, scale = 0)
private Double number;
private Double wholeNumber;
public ScalePrecisionEntity() {
}
public ScalePrecisionEntity(Double number) {
this.number = number;
public ScalePrecisionEntity(Double wholeNumber) {
this.wholeNumber = wholeNumber;
}
public ScalePrecisionEntity(Double number, Long id) {
public ScalePrecisionEntity(Double wholeNumber, Long id) {
this.id = id;
this.number = number;
this.wholeNumber = wholeNumber;
}
@Override
@ -41,7 +41,7 @@ public class ScalePrecisionEntity implements Serializable {
ScalePrecisionEntity that = (ScalePrecisionEntity) o;
if (id != null ? !id.equals(that.id) : that.id != null) return false;
if (number != null ? !number.equals(that.number) : that.number != null) return false;
if (wholeNumber != null ? !wholeNumber.equals(that.wholeNumber) : that.wholeNumber != null) return false;
return true;
}
@ -49,13 +49,13 @@ public class ScalePrecisionEntity implements Serializable {
@Override
public int hashCode() {
int result = id != null ? id.hashCode() : 0;
result = 31 * result + (number != null ? number.hashCode() : 0);
result = 31 * result + (wholeNumber != null ? wholeNumber.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "ScalePrecisionEntity(id = " + id + ", number = " + number + ")";
return "ScalePrecisionEntity(id = " + id + ", wholeNumber = " + wholeNumber + ")";
}
public Long getId() {
@ -66,11 +66,11 @@ public class ScalePrecisionEntity implements Serializable {
this.id = id;
}
public Double getNumber() {
return number;
public Double getWholeNumber() {
return wholeNumber;
}
public void setNumber(Double number) {
this.number = number;
public void setWholeNumber(Double wholeNumber) {
this.wholeNumber = wholeNumber;
}
}

View File

@ -29,6 +29,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.MapKey;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
import org.hibernate.envers.test.entities.components.Component1;
@ -38,6 +39,7 @@ import org.hibernate.envers.test.entities.components.ComponentTestEntity;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "CompMapKey")
public class ComponentMapKeyEntity {
@Id
@GeneratedValue

View File

@ -29,6 +29,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.MapKey;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
import org.hibernate.envers.test.entities.StrTestEntity;
@ -37,6 +38,7 @@ import org.hibernate.envers.test.entities.StrTestEntity;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "IdMapKey")
public class IdMapKeyEntity {
@Id
@GeneratedValue

View File

@ -353,15 +353,15 @@ public class DefaultValueComponents extends AbstractEntityTest {
"select count(s) from DefaultValueComponentTestEntity s where s.id = "
+ expectedId.toString()).getSingleResult();
Number auditCount = (Number) em.createNativeQuery(
"select count(ID) from DefaultValueComponentTestEntity_AUD s where s.id = "
"select count(ID) from DefaultValueComponent_AUD s where s.id = "
+ expectedId.toString()).getSingleResult();
String comp2Str1Rev1 = (String) em
.createNativeQuery(
"select COMP2_STR1 from DefaultValueComponentTestEntity_AUD s where rev=1 and s.id = "
"select COMP2_STR1 from DefaultValueComponent_AUD s where rev=1 and s.id = "
+ expectedId.toString()).getSingleResult();
String comp2Str1Rev2 = (String) em
.createNativeQuery(
"select COMP2_STR1 from DefaultValueComponentTestEntity_AUD s where rev=2 and s.id = "
"select COMP2_STR1 from DefaultValueComponent_AUD s where rev=2 and s.id = "
+ expectedId.toString()).getSingleResult();
assert Long.valueOf(1L).equals(entCount);
assert Integer.valueOf(2).equals(auditCount.intValue());

View File

@ -39,18 +39,18 @@ public class DateTestEntity {
private Integer id;
@Audited
private Date date;
private Date dateValue;
public DateTestEntity() {
}
public DateTestEntity(Date date) {
this.date = date;
public DateTestEntity(Date dateValue) {
this.dateValue = dateValue;
}
public DateTestEntity(Integer id, Date date) {
this.id = id;
this.date = date;
this.dateValue = dateValue;
}
public Integer getId() {
@ -61,12 +61,12 @@ public class DateTestEntity {
this.id = id;
}
public Date getDate() {
return date;
public Date getDateValue() {
return dateValue;
}
public void setDate(Date date) {
this.date = date;
public void setDateValue(Date dateValue) {
this.dateValue = dateValue;
}
public boolean equals(Object o) {
@ -75,12 +75,12 @@ public class DateTestEntity {
DateTestEntity that = (DateTestEntity) o;
if (date != null) {
if (that.date == null) {
if (dateValue != null) {
if (that.dateValue == null) {
return false;
}
if (date.getTime() != that.date.getTime()) {
if (dateValue.getTime() != that.dateValue.getTime()) {
return false;
}
}
@ -93,7 +93,7 @@ public class DateTestEntity {
public int hashCode() {
int result;
result = (id != null ? id.hashCode() : 0);
result = 31 * result + (date != null ? date.hashCode() : 0);
result = 31 * result + (dateValue != null ? dateValue.hashCode() : 0);
return result;
}
}

View File

@ -27,6 +27,7 @@ import java.util.Arrays;
import java.util.Date;
import javax.persistence.EntityManager;
import org.junit.Assert;
import org.junit.Test;
import org.hibernate.ejb.Ejb3Configuration;
@ -55,7 +56,7 @@ public class Dates extends AbstractEntityTest {
em.getTransaction().begin();
dte = em.find(DateTestEntity.class, id1);
dte.setDate(new Date(45678000));
dte.setDateValue(new Date(45678000));
em.getTransaction().commit();
}
@ -69,7 +70,7 @@ public class Dates extends AbstractEntityTest {
DateTestEntity ver1 = new DateTestEntity(id1, new Date(12345000));
DateTestEntity ver2 = new DateTestEntity(id1, new Date(45678000));
assert getAuditReader().find(DateTestEntity.class, id1, 1).equals(ver1);
assert getAuditReader().find(DateTestEntity.class, id1, 2).equals(ver2);
Assert.assertEquals(ver1, getAuditReader().find(DateTestEntity.class, id1, 1));
Assert.assertEquals(ver2, getAuditReader().find(DateTestEntity.class, id1, 2));
}
}

View File

@ -13,15 +13,15 @@ public class Car {
private long id;
private int number;
private int registrationNumber;
private List<Person> owners;
public Car() { }
public Car(int number, List<Person> owners) {
this.number = number;
public Car(int registrationNumber, List<Person> owners) {
this.registrationNumber = registrationNumber;
this.owners = owners;
}
@ -42,12 +42,12 @@ public class Car {
this.owners = owners;
}
public int getNumber() {
return number;
public int getRegistrationNumber() {
return registrationNumber;
}
public void setNumber(int number) {
this.number = number;
public void setRegistrationNumber(int registrationNumber) {
this.registrationNumber = registrationNumber;
}

View File

@ -83,12 +83,12 @@ public class ReadEntityWithAuditedManyToManyTest extends AbstractOneSessionTest{
// navigate through relations to load objects
for (Person owner : car1_2.getOwners()) {
for (Car ownedCar : owner.getCars()) {
ownedCar.getNumber();
ownedCar.getRegistrationNumber();
}
}
for (Person owner : car2_2.getOwners()) {
for (Car ownedCar : owner.getCars()) {
ownedCar.getNumber();
ownedCar.getRegistrationNumber();
}
}

View File

@ -61,7 +61,7 @@ public class ChildAuditing extends AbstractEntityTest {
em.getTransaction().begin();
ce = em.find(ChildEntity.class, id1);
ce.setData("y");
ce.setNumber(2l);
ce.setNumVal(2l);
em.getTransaction().commit();
}

View File

@ -35,22 +35,22 @@ import org.hibernate.envers.Audited;
@Audited
public class ChildEntity extends ParentEntity {
@Basic
private Long number;
private Long numVal;
public ChildEntity() {
}
public ChildEntity(Integer id, String data, Long number) {
public ChildEntity(Integer id, String data, Long numVal) {
super(id, data);
this.number = number;
this.numVal = numVal;
}
public Long getNumber() {
return number;
public Long getNumVal() {
return numVal;
}
public void setNumber(Long number) {
this.number = number;
public void setNumVal(Long numVal) {
this.numVal = numVal;
}
public boolean equals(Object o) {
@ -60,18 +60,18 @@ public class ChildEntity extends ParentEntity {
ChildEntity childEntity = (ChildEntity) o;
if (number != null ? !number.equals(childEntity.number) : childEntity.number != null) return false;
if (numVal != null ? !numVal.equals(childEntity.numVal) : childEntity.numVal != null) return false;
return true;
}
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (number != null ? number.hashCode() : 0);
result = 31 * result + (numVal != null ? numVal.hashCode() : 0);
return result;
}
public String toString() {
return "ChildEntity(id = " + getId() + ", data = " + getData() + ", number = " + number + ")";
return "ChildEntity(id = " + getId() + ", data = " + getData() + ", numVal = " + numVal + ")";
}
}

View File

@ -61,7 +61,7 @@ public class ChildNullAuditing extends AbstractEntityTest {
em.getTransaction().begin();
ce = em.find(ChildEntity.class, id1);
ce.setData(null);
ce.setNumber(2l);
ce.setNumVal(2l);
em.getTransaction().commit();
}

View File

@ -36,7 +36,7 @@ import org.hibernate.envers.Audited;
@Audited
public class ChildIngEntity extends ParentNotIngEntity {
@Basic
private Long number;
private Long numVal;
@ManyToOne
private ReferencedEntity referenced;
@ -44,17 +44,17 @@ public class ChildIngEntity extends ParentNotIngEntity {
public ChildIngEntity() {
}
public ChildIngEntity(Integer id, String data, Long number) {
public ChildIngEntity(Integer id, String data, Long numVal) {
super(id, data);
this.number = number;
this.numVal = numVal;
}
public Long getNumber() {
return number;
public Long getNumVal() {
return numVal;
}
public void setNumber(Long number) {
this.number = number;
public void setNumVal(Long numVal) {
this.numVal = numVal;
}
public ReferencedEntity getReferenced() {
@ -72,18 +72,18 @@ public class ChildIngEntity extends ParentNotIngEntity {
ChildIngEntity childEntity = (ChildIngEntity) o;
if (number != null ? !number.equals(childEntity.number) : childEntity.number != null) return false;
if (numVal != null ? !numVal.equals(childEntity.numVal) : childEntity.numVal != null) return false;
return true;
}
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (number != null ? number.hashCode() : 0);
result = 31 * result + (numVal != null ? numVal.hashCode() : 0);
return result;
}
public String toString() {
return "ChildIngEntity(id = " + getId() + ", data = " + getData() + ", number = " + number + ")";
return "ChildIngEntity(id = " + getId() + ", data = " + getData() + ", numVal = " + numVal + ")";
}
}

View File

@ -64,7 +64,7 @@ public class ChildPrimaryKeyJoinAuditing extends AbstractEntityTest {
em.getTransaction().begin();
ce = em.find(ChildPrimaryKeyJoinEntity.class, id1);
ce.setData("y");
ce.setNumber(2l);
ce.setNumVal(2l);
em.getTransaction().commit();
}

View File

@ -38,22 +38,22 @@ import org.hibernate.envers.test.integration.inheritance.joined.ParentEntity;
@PrimaryKeyJoinColumn(name = "other_id")
public class ChildPrimaryKeyJoinEntity extends ParentEntity {
@Basic
private Long number;
private Long namVal;
public ChildPrimaryKeyJoinEntity() {
}
public ChildPrimaryKeyJoinEntity(Integer id, String data, Long number) {
public ChildPrimaryKeyJoinEntity(Integer id, String data, Long namVal) {
super(id, data);
this.number = number;
this.namVal = namVal;
}
public Long getNumber() {
return number;
public Long getNumVal() {
return namVal;
}
public void setNumber(Long number) {
this.number = number;
public void setNumVal(Long namVal) {
this.namVal = namVal;
}
public boolean equals(Object o) {
@ -64,18 +64,18 @@ public class ChildPrimaryKeyJoinEntity extends ParentEntity {
ChildPrimaryKeyJoinEntity childPrimaryKeyJoinEntity = (ChildPrimaryKeyJoinEntity) o;
//noinspection RedundantIfStatement
if (number != null ? !number.equals(childPrimaryKeyJoinEntity.number) : childPrimaryKeyJoinEntity.number != null) return false;
if (namVal != null ? !namVal.equals(childPrimaryKeyJoinEntity.namVal) : childPrimaryKeyJoinEntity.namVal != null) return false;
return true;
}
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (number != null ? number.hashCode() : 0);
result = 31 * result + (namVal != null ? namVal.hashCode() : 0);
return result;
}
public String toString() {
return "CPKJE(id = " + getId() + ", data = " + getData() + ", number = " + number + ")";
return "CPKJE(id = " + getId() + ", data = " + getData() + ", namVal = " + namVal + ")";
}
}

View File

@ -35,22 +35,22 @@ import org.hibernate.envers.Audited;
@Audited
public class ChildIngEntity extends ParentIngEntity {
@Basic
private Long number;
private Long numVal;
public ChildIngEntity() {
}
public ChildIngEntity(Integer id, String data, Long number) {
public ChildIngEntity(Integer id, String data, Long numVal) {
super(id, data);
this.number = number;
this.numVal = numVal;
}
public Long getNumber() {
return number;
public Long getNumVal() {
return numVal;
}
public void setNumber(Long number) {
this.number = number;
public void setNumVal(Long numVal) {
this.numVal = numVal;
}
public boolean equals(Object o) {
@ -60,18 +60,18 @@ public class ChildIngEntity extends ParentIngEntity {
ChildIngEntity childEntity = (ChildIngEntity) o;
if (number != null ? !number.equals(childEntity.number) : childEntity.number != null) return false;
if (numVal != null ? !numVal.equals(childEntity.numVal) : childEntity.numVal != null) return false;
return true;
}
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (number != null ? number.hashCode() : 0);
result = 31 * result + (numVal != null ? numVal.hashCode() : 0);
return result;
}
public String toString() {
return "ChildIngEntity(id = " + getId() + ", data = " + getData() + ", number = " + number + ")";
return "ChildIngEntity(id = " + getId() + ", data = " + getData() + ", numVal = " + numVal + ")";
}
}

View File

@ -28,6 +28,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -35,6 +36,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "AbstrContained")
@Audited
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class AbstractContainedEntity {

View File

@ -31,6 +31,7 @@ import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -38,6 +39,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "AbstrSet")
@Inheritance(strategy = InheritanceType.JOINED)
@Audited
public abstract class AbstractSetEntity {

View File

@ -24,6 +24,7 @@
package org.hibernate.envers.test.integration.inheritance.joined.relation.unidirectional;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -31,6 +32,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "Contained")
@Audited
public class ContainedEntity extends AbstractContainedEntity {
}

View File

@ -59,7 +59,7 @@ public class ChildAuditing extends AbstractEntityTest {
em.getTransaction().begin();
ce = em.find(ChildEntity.class, id1);
ce.setData("y");
ce.setNumber(2l);
ce.setNumVal(2l);
em.getTransaction().commit();
}

View File

@ -36,27 +36,27 @@ import org.hibernate.envers.Audited;
@Audited
public class ChildEntity extends ParentEntity {
@Basic
private Long number;
private Long numVal;
public ChildEntity() {
}
public ChildEntity(String data, Long number) {
public ChildEntity(String data, Long numVal) {
super(data);
this.number = number;
this.numVal = numVal;
}
public ChildEntity(Integer id, String data, Long number) {
public ChildEntity(Integer id, String data, Long numVal) {
super(id, data);
this.number = number;
this.numVal = numVal;
}
public Long getNumber() {
return number;
public Long getNumVal() {
return numVal;
}
public void setNumber(Long number) {
this.number = number;
public void setNumVal(Long numVal) {
this.numVal = numVal;
}
public boolean equals(Object o) {
@ -66,18 +66,18 @@ public class ChildEntity extends ParentEntity {
ChildEntity childEntity = (ChildEntity) o;
if (number != null ? !number.equals(childEntity.number) : childEntity.number != null) return false;
if (numVal != null ? !numVal.equals(childEntity.numVal) : childEntity.numVal != null) return false;
return true;
}
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (number != null ? number.hashCode() : 0);
result = 31 * result + (numVal != null ? numVal.hashCode() : 0);
return result;
}
public String toString() {
return "ChildPrimaryKeyJoinEntity(id = " + getId() + ", data = " + getData() + ", number = " + number + ")";
return "ChildPrimaryKeyJoinEntity(id = " + getId() + ", data = " + getData() + ", numVal = " + numVal + ")";
}
}

View File

@ -37,7 +37,7 @@ import org.hibernate.envers.Audited;
@Audited
public class ChildIngEntity extends ParentNotIngEntity {
@Basic
private Long number;
private Long numVal;
@ManyToOne
private ReferencedEntity referenced;
@ -45,22 +45,22 @@ public class ChildIngEntity extends ParentNotIngEntity {
public ChildIngEntity() {
}
public ChildIngEntity(String data, Long number) {
public ChildIngEntity(String data, Long numVal) {
super(data);
this.number = number;
this.numVal = numVal;
}
public ChildIngEntity(Integer id, String data, Long number) {
public ChildIngEntity(Integer id, String data, Long numVal) {
super(id, data);
this.number = number;
this.numVal = numVal;
}
public Long getNumber() {
return number;
public Long getNumVal() {
return numVal;
}
public void setNumber(Long number) {
this.number = number;
public void setNumVal(Long numVal) {
this.numVal = numVal;
}
public ReferencedEntity getReferenced() {
@ -78,18 +78,18 @@ public class ChildIngEntity extends ParentNotIngEntity {
ChildIngEntity childEntity = (ChildIngEntity) o;
if (number != null ? !number.equals(childEntity.number) : childEntity.number != null) return false;
if (numVal != null ? !numVal.equals(childEntity.numVal) : childEntity.numVal != null) return false;
return true;
}
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (number != null ? number.hashCode() : 0);
result = 31 * result + (numVal != null ? numVal.hashCode() : 0);
return result;
}
public String toString() {
return "ChildIngEntity(id = " + getId() + ", data = " + getData() + ", number = " + number + ")";
return "ChildIngEntity(id = " + getId() + ", data = " + getData() + ", numVal = " + numVal + ")";
}
}

View File

@ -5,6 +5,7 @@ import java.util.Iterator;
import java.util.List;
import javax.persistence.EntityManager;
import org.junit.Assert;
import org.junit.Test;
import org.hibernate.ejb.Ejb3Configuration;
@ -93,7 +94,7 @@ public class DiscriminatorFormulaTest extends AbstractEntityTest {
Object o = iterator.next();
if (o instanceof Formula) {
Formula formula = (Formula) o;
assert formula.getText().equals(ParentEntity.DISCRIMINATOR_QUERY);
Assert.assertEquals(ParentEntity.DISCRIMINATOR_QUERY, formula.getText());
return;
}
}
@ -102,31 +103,31 @@ public class DiscriminatorFormulaTest extends AbstractEntityTest {
@Test
public void testRevisionsCounts() {
assert Arrays.asList(1, 3).equals(getAuditReader().getRevisions(ChildEntity.class, childVer1.getId()));
assert Arrays.asList(2, 4).equals(getAuditReader().getRevisions(ParentEntity.class, parentVer1.getId()));
Assert.assertEquals(Arrays.asList(1, 3), getAuditReader().getRevisions(ChildEntity.class, childVer1.getId()));
Assert.assertEquals(Arrays.asList(2, 4), getAuditReader().getRevisions(ParentEntity.class, parentVer1.getId()));
}
@Test
public void testHistoryOfParent() {
assert getAuditReader().find(ParentEntity.class, parentVer1.getId(), 2).equals(parentVer1);
assert getAuditReader().find(ParentEntity.class, parentVer2.getId(), 4).equals(parentVer2);
Assert.assertEquals(parentVer1, getAuditReader().find(ParentEntity.class, parentVer1.getId(), 2));
Assert.assertEquals(parentVer2, getAuditReader().find(ParentEntity.class, parentVer2.getId(), 4));
}
@Test
public void testHistoryOfChild() {
assert getAuditReader().find(ChildEntity.class, childVer1.getId(), 1).equals(childVer1);
assert getAuditReader().find(ChildEntity.class, childVer2.getId(), 3).equals(childVer2);
Assert.assertEquals(childVer1, getAuditReader().find(ChildEntity.class, childVer1.getId(), 1));
Assert.assertEquals(childVer2, getAuditReader().find(ChildEntity.class, childVer2.getId(), 3));
}
@Test
public void testPolymorphicQuery() {
assert getAuditReader().createQuery().forEntitiesAtRevision(ChildEntity.class, 1).getSingleResult().equals(childVer1);
assert getAuditReader().createQuery().forEntitiesAtRevision(ParentEntity.class, 1).getSingleResult().equals(childVer1);
Assert.assertEquals(childVer1, getAuditReader().createQuery().forEntitiesAtRevision(ChildEntity.class, 1).getSingleResult());
Assert.assertEquals(childVer1, getAuditReader().createQuery().forEntitiesAtRevision(ParentEntity.class, 1).getSingleResult());
List childEntityRevisions = getAuditReader().createQuery().forRevisionsOfEntity(ChildEntity.class, true, false).getResultList();
assert Arrays.asList(childVer1, childVer2).equals(childEntityRevisions);
Assert.assertEquals(Arrays.asList(childVer1, childVer2), childEntityRevisions);
List parentEntityRevisions = getAuditReader().createQuery().forRevisionsOfEntity(ParentEntity.class, true, false).getResultList();
assert Arrays.asList(childVer1, parentVer1, childVer2, parentVer2).equals(parentEntityRevisions);
Assert.assertEquals(Arrays.asList(childVer1, parentVer1, childVer2, parentVer2), parentEntityRevisions);
}
}

View File

@ -47,7 +47,7 @@ public class ParentEntity {
ParentEntity that = (ParentEntity) o;
if (id != null ? !id.equals(that.id) : that.id != null) return false;
if (typeId != null ? !typeId.equals(that.id) : that.typeId != null) return false;
if (typeId != null ? !typeId.equals(that.typeId) : that.typeId != null) return false;
if (data != null ? !data.equals(that.data) : that.data != null) return false;
return true;

View File

@ -36,27 +36,27 @@ import org.hibernate.envers.Audited;
@Audited
public class ChildIngEntity extends ParentIngEntity {
@Basic
private Long number;
private Long numVal;
public ChildIngEntity() {
}
public ChildIngEntity(String data, Long number) {
public ChildIngEntity(String data, Long numVal) {
super(data);
this.number = number;
this.numVal = numVal;
}
public ChildIngEntity(Integer id, String data, Long number) {
public ChildIngEntity(Integer id, String data, Long numVal) {
super(id, data);
this.number = number;
this.numVal = numVal;
}
public Long getNumber() {
return number;
public Long getNumVal() {
return numVal;
}
public void setNumber(Long number) {
this.number = number;
public void setNumVal(Long numVal) {
this.numVal = numVal;
}
public boolean equals(Object o) {
@ -66,18 +66,18 @@ public class ChildIngEntity extends ParentIngEntity {
ChildIngEntity childEntity = (ChildIngEntity) o;
if (number != null ? !number.equals(childEntity.number) : childEntity.number != null) return false;
if (numVal != null ? !numVal.equals(childEntity.numVal) : childEntity.numVal != null) return false;
return true;
}
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (number != null ? number.hashCode() : 0);
result = 31 * result + (numVal != null ? numVal.hashCode() : 0);
return result;
}
public String toString() {
return "ChildIngEntity(id = " + getId() + ", data = " + getData() + ", number = " + number + ")";
return "ChildIngEntity(id = " + getId() + ", data = " + getData() + ", numVal = " + numVal + ")";
}
}

View File

@ -61,7 +61,7 @@ public class ChildAuditing extends AbstractEntityTest {
em.getTransaction().begin();
ce = em.find(ChildEntity.class, id1);
ce.setData("y");
ce.setNumber(2l);
ce.setNumVal(2l);
em.getTransaction().commit();
}

View File

@ -35,22 +35,22 @@ import org.hibernate.envers.Audited;
@Audited
public class ChildEntity extends ParentEntity {
@Basic
private Long number;
private Long numVal;
public ChildEntity() {
}
public ChildEntity(Integer id, String data, Long number) {
public ChildEntity(Integer id, String data, Long numVal) {
super(id, data);
this.number = number;
this.numVal = numVal;
}
public Long getNumber() {
return number;
public Long getNumVal() {
return numVal;
}
public void setNumber(Long number) {
this.number = number;
public void setNumVal(Long numVal) {
this.numVal = numVal;
}
public boolean equals(Object o) {
@ -60,18 +60,18 @@ public class ChildEntity extends ParentEntity {
ChildEntity childEntity = (ChildEntity) o;
if (number != null ? !number.equals(childEntity.number) : childEntity.number != null) return false;
if (numVal != null ? !numVal.equals(childEntity.numVal) : childEntity.numVal != null) return false;
return true;
}
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (number != null ? number.hashCode() : 0);
result = 31 * result + (numVal != null ? numVal.hashCode() : 0);
return result;
}
public String toString() {
return "ChildPrimaryKeyJoinEntity(id = " + getId() + ", data = " + getData() + ", number = " + number + ")";
return "ChildPrimaryKeyJoinEntity(id = " + getId() + ", data = " + getData() + ", numVal = " + numVal + ")";
}
}

View File

@ -36,7 +36,7 @@ import org.hibernate.envers.Audited;
@Audited
public class ChildIngEntity extends ParentNotIngEntity {
@Basic
private Long number;
private Long numVal;
@ManyToOne
private ReferencedEntity referenced;
@ -44,17 +44,17 @@ public class ChildIngEntity extends ParentNotIngEntity {
public ChildIngEntity() {
}
public ChildIngEntity(Integer id, String data, Long number) {
public ChildIngEntity(Integer id, String data, Long numVal) {
super(id, data);
this.number = number;
this.numVal = numVal;
}
public Long getNumber() {
return number;
public Long getNumVal() {
return numVal;
}
public void setNumber(Long number) {
this.number = number;
public void setNumVal(Long numVal) {
this.numVal = numVal;
}
public ReferencedEntity getReferenced() {
@ -72,18 +72,18 @@ public class ChildIngEntity extends ParentNotIngEntity {
ChildIngEntity childEntity = (ChildIngEntity) o;
if (number != null ? !number.equals(childEntity.number) : childEntity.number != null) return false;
if (numVal != null ? !numVal.equals(childEntity.numVal) : childEntity.numVal != null) return false;
return true;
}
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (number != null ? number.hashCode() : 0);
result = 31 * result + (numVal != null ? numVal.hashCode() : 0);
return result;
}
public String toString() {
return "ChildIngEntity(id = " + getId() + ", data = " + getData() + ", number = " + number + ")";
return "ChildIngEntity(id = " + getId() + ", data = " + getData() + ", numVal = " + numVal + ")";
}
}

View File

@ -35,22 +35,22 @@ import org.hibernate.envers.Audited;
@Audited
public class ChildIngEntity extends ParentIngEntity {
@Basic
private Long number;
private Long numVal;
public ChildIngEntity() {
}
public ChildIngEntity(Integer id, String data, Long number) {
public ChildIngEntity(Integer id, String data, Long numVal) {
super(id, data);
this.number = number;
this.numVal = numVal;
}
public Long getNumber() {
return number;
public Long getNumVal() {
return numVal;
}
public void setNumber(Long number) {
this.number = number;
public void setNumVal(Long numVal) {
this.numVal = numVal;
}
public boolean equals(Object o) {
@ -60,18 +60,18 @@ public class ChildIngEntity extends ParentIngEntity {
ChildIngEntity childEntity = (ChildIngEntity) o;
if (number != null ? !number.equals(childEntity.number) : childEntity.number != null) return false;
if (numVal != null ? !numVal.equals(childEntity.numVal) : childEntity.numVal != null) return false;
return true;
}
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (number != null ? number.hashCode() : 0);
result = 31 * result + (numVal != null ? numVal.hashCode() : 0);
return result;
}
public String toString() {
return "ChildIngEntity(id = " + getId() + ", data = " + getData() + ", number = " + number + ")";
return "ChildIngEntity(id = " + getId() + ", data = " + getData() + ", numVal = " + numVal + ")";
}
}

View File

@ -27,10 +27,10 @@ import java.util.Properties;
import javax.persistence.EntityManager;
import javax.transaction.RollbackException;
import org.hibernate.dialect.Dialect;
import org.junit.Assert;
import org.junit.Test;
import org.hibernate.AssertionFailure;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.Priority;
@ -46,6 +46,10 @@ import org.hibernate.testing.jta.TestingJtaBootstrap;
public class JtaExceptionListener extends AbstractEntityTest {
public void configure(Ejb3Configuration cfg) {
cfg.addAnnotatedClass(StrTestEntity.class);
}
@Override
protected void revisionEntityForDialect(Ejb3Configuration cfg, Dialect dialect, Properties configurationProperties) {
cfg.addAnnotatedClass(ExceptionListenerRevEntity.class);
}

View File

@ -190,11 +190,11 @@ public class BasicBiowned extends AbstractEntityTest {
ListBiowning1Entity o1_1 = getEntityManager().find(ListBiowning1Entity.class, o1_1_id);
ListBiowning1Entity o1_2 = getEntityManager().find(ListBiowning1Entity.class, o1_2_id);
ListBiowning2Entity rev1 = getAuditReader().find(ListBiowning2Entity.class, o1_1_id, 1);
ListBiowning2Entity rev2 = getAuditReader().find(ListBiowning2Entity.class, o1_1_id, 2);
ListBiowning2Entity rev3 = getAuditReader().find(ListBiowning2Entity.class, o1_1_id, 3);
ListBiowning2Entity rev4 = getAuditReader().find(ListBiowning2Entity.class, o1_1_id, 4);
ListBiowning2Entity rev5 = getAuditReader().find(ListBiowning2Entity.class, o1_1_id, 5);
ListBiowning2Entity rev1 = getAuditReader().find(ListBiowning2Entity.class, o2_1_id, 1);
ListBiowning2Entity rev2 = getAuditReader().find(ListBiowning2Entity.class, o2_1_id, 2);
ListBiowning2Entity rev3 = getAuditReader().find(ListBiowning2Entity.class, o2_1_id, 3);
ListBiowning2Entity rev4 = getAuditReader().find(ListBiowning2Entity.class, o2_1_id, 4);
ListBiowning2Entity rev5 = getAuditReader().find(ListBiowning2Entity.class, o2_1_id, 5);
assert TestTools.checkList(rev1.getReferences());
assert TestTools.checkList(rev2.getReferences(), o1_1);
@ -208,11 +208,11 @@ public class BasicBiowned extends AbstractEntityTest {
ListBiowning1Entity o1_1 = getEntityManager().find(ListBiowning1Entity.class, o1_1_id);
ListBiowning1Entity o1_2 = getEntityManager().find(ListBiowning1Entity.class, o1_2_id);
ListBiowning2Entity rev1 = getAuditReader().find(ListBiowning2Entity.class, o1_2_id, 1);
ListBiowning2Entity rev2 = getAuditReader().find(ListBiowning2Entity.class, o1_2_id, 2);
ListBiowning2Entity rev3 = getAuditReader().find(ListBiowning2Entity.class, o1_2_id, 3);
ListBiowning2Entity rev4 = getAuditReader().find(ListBiowning2Entity.class, o1_2_id, 4);
ListBiowning2Entity rev5 = getAuditReader().find(ListBiowning2Entity.class, o1_2_id, 5);
ListBiowning2Entity rev1 = getAuditReader().find(ListBiowning2Entity.class, o2_2_id, 1);
ListBiowning2Entity rev2 = getAuditReader().find(ListBiowning2Entity.class, o2_2_id, 2);
ListBiowning2Entity rev3 = getAuditReader().find(ListBiowning2Entity.class, o2_2_id, 3);
ListBiowning2Entity rev4 = getAuditReader().find(ListBiowning2Entity.class, o2_2_id, 4);
ListBiowning2Entity rev5 = getAuditReader().find(ListBiowning2Entity.class, o2_2_id, 5);
assert TestTools.checkList(rev1.getReferences());
assert TestTools.checkList(rev2.getReferences(), o1_2);

View File

@ -26,6 +26,8 @@ package org.hibernate.envers.test.integration.manytomany.sametable;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.dialect.Oracle8iDialect;
import org.junit.Assert;
import org.junit.Test;
import org.hibernate.Session;
@ -67,7 +69,8 @@ public class BasicSametable extends AbstractEntityTest {
session.createSQLQuery("DROP TABLE children").executeUpdate();
session.createSQLQuery("CREATE TABLE children(parent_id integer, child1_id integer NULL, child2_id integer NULL)").executeUpdate();
session.createSQLQuery("DROP TABLE children_AUD").executeUpdate();
session.createSQLQuery("CREATE TABLE children_AUD(REV integer NOT NULL, REVEND integer, REVTYPE tinyint, " +
session.createSQLQuery("CREATE TABLE children_AUD(REV integer NOT NULL, REVEND integer, REVTYPE " +
(getDialect() instanceof Oracle8iDialect ? "number(3,0)" : "tinyint") + ", " +
"parent_id integer, child1_id integer NULL, child2_id integer NULL)").executeUpdate();
em.getTransaction().commit();
em.clear();
@ -172,8 +175,8 @@ public class BasicSametable extends AbstractEntityTest {
assert Arrays.asList(1).equals(getAuditReader().getRevisions(Child1Entity.class, c1_1_id));
assert Arrays.asList(1, 5).equals(getAuditReader().getRevisions(Child1Entity.class, c1_2_id));
assert Arrays.asList(1).equals(getAuditReader().getRevisions(Child1Entity.class, c2_1_id));
assert Arrays.asList(1, 5).equals(getAuditReader().getRevisions(Child1Entity.class, c2_2_id));
Assert.assertEquals(Arrays.asList(1), getAuditReader().getRevisions(Child2Entity.class, c2_1_id));
Assert.assertEquals(Arrays.asList(1, 5), getAuditReader().getRevisions(Child2Entity.class, c2_2_id));
}
@Test

View File

@ -26,6 +26,7 @@ package org.hibernate.envers.test.integration.manytomany.ternary;
import java.util.Arrays;
import javax.persistence.EntityManager;
import org.junit.Assert;
import org.junit.Test;
import org.hibernate.ejb.Ejb3Configuration;
@ -174,10 +175,10 @@ public class TernaryMap extends AbstractEntityTest {
TernaryMapEntity rev3 = getAuditReader().find(TernaryMapEntity.class, map1_id, 3);
TernaryMapEntity rev4 = getAuditReader().find(TernaryMapEntity.class, map1_id, 4);
assert rev1.getMap().equals(TestTools.makeMap(int1, str1));
assert rev2.getMap().equals(TestTools.makeMap(int1, str2));
assert rev3.getMap().equals(TestTools.makeMap(int1, str2));
assert rev4.getMap().equals(TestTools.makeMap(int1, str2, int2, str2));
Assert.assertEquals(TestTools.makeMap(int1, str1), rev1.getMap());
Assert.assertEquals(TestTools.makeMap(int1, str2), rev2.getMap());
Assert.assertEquals(TestTools.makeMap(int1, str2), rev3.getMap());
Assert.assertEquals(TestTools.makeMap(int1, str2, int2, str2), rev4.getMap());
}
@Test

View File

@ -67,7 +67,7 @@ public class HasChangedChildAuditing extends AbstractModifiedFlagsEntityTest {
em.getTransaction().begin();
ce = em.find(ChildEntity.class, id1);
ce.setData("y");
ce.setNumber(2l);
ce.setNumVal(2l);
em.getTransaction().commit();
}
@ -77,14 +77,14 @@ public class HasChangedChildAuditing extends AbstractModifiedFlagsEntityTest {
assertEquals(2, list.size());
assertEquals(makeList(1, 2), extractRevisionNumbers(list));
list = queryForPropertyHasChanged(ChildEntity.class, id1, "number");
list = queryForPropertyHasChanged(ChildEntity.class, id1, "numVal");
assertEquals(2, list.size());
assertEquals(makeList(1, 2), extractRevisionNumbers(list));
list = queryForPropertyHasNotChanged(ChildEntity.class, id1, "data");
assertEquals(0, list.size());
list = queryForPropertyHasNotChanged(ChildEntity.class, id1, "number");
list = queryForPropertyHasNotChanged(ChildEntity.class, id1, "numVal");
assertEquals(0, list.size());
}

View File

@ -10,7 +10,7 @@ import javax.persistence.Table;
* @see VersionsJoinTableRangeTestEntitySuperClass
*/
@Entity
@Table(name = "RANGE_TEST_ALTERNATE_ENTITY")
@Table(name = "RANGE_TEST_ALTERNATE_ENT")
@org.hibernate.envers.Audited
public class VersionsJoinTableRangeTestAlternateEntity extends
VersionsJoinTableRangeTestEntitySuperClass {

View File

@ -27,6 +27,7 @@ import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.envers.AuditJoinTable;
import org.hibernate.envers.Audited;
@ -36,6 +37,7 @@ import org.hibernate.envers.test.entities.StrTestEntity;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "VersionsJoinTable")
public class VersionsJoinTableTestEntity {
@Id
private Integer id;

View File

@ -27,6 +27,7 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -35,6 +36,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "JoinEmbIdRefEd")
public class JoinEmbIdNamingRefEdEntity {
@Id
@GeneratedValue

View File

@ -28,6 +28,7 @@ import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -36,6 +37,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "JoinEmbIdRefIng")
public class JoinEmbIdNamingRefIngEntity {
@Id
@GeneratedValue

View File

@ -27,6 +27,7 @@ import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -35,6 +36,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "JoinMulIdRefEd")
@IdClass(MulIdNaming.class)
public class JoinMulIdNamingRefEdEntity {
@Id

View File

@ -23,11 +23,13 @@
*/
package org.hibernate.envers.test.integration.naming.ids;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@ -36,6 +38,7 @@ import org.hibernate.envers.Audited;
* @author Adam Warski (adam at warski dot org)
*/
@Entity
@Table(name = "JoinMulIdRefIng")
@IdClass(MulIdNaming.class)
public class JoinMulIdNamingRefIngEntity {
@Id

View File

@ -5,21 +5,23 @@ import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@Entity
@Table(name = "ManyToOneNotIns")
@Audited
public class ManyToOneNotInsertableEntity {
@Id
private Integer id;
@Basic
@Column(name = "number")
@Column(name = "numVal")
private Integer number;
@ManyToOne
@JoinColumn(name = "number", insertable = false, updatable = false)
@JoinColumn(name = "numVal", insertable = false, updatable = false)
private NotInsertableEntityType type;
public ManyToOneNotInsertableEntity() { }

View File

@ -59,8 +59,8 @@ public class PrimitiveAddDelete extends AbstractEntityTest {
// Revision 2
em.getTransaction().begin();
pte = em.find(PrimitiveTestEntity.class, id1);
pte.setNumber(20);
pte.setNumber2(21);
pte.setNumVal1(20);
pte.setNumVal2(21);
em.getTransaction().commit();
// Revision 3

View File

@ -25,6 +25,7 @@ package org.hibernate.envers.test.integration.properties;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Version;
import org.hibernate.envers.Audited;
@ -33,6 +34,7 @@ import org.hibernate.envers.Audited;
* @author Nicolas Doroskevich
*/
@Audited
@Table(name = "UnverOptimLockField")
@Entity
public class UnversionedOptimisticLockingFieldEntity {

Some files were not shown because too many files have changed in this diff Show More