HHH-8908 : Column of Embedded missing in Audit Table
This commit is contained in:
parent
0638c964ee
commit
d7173eeb3a
|
@ -482,6 +482,7 @@ public final class CollectionMetadataGenerator {
|
||||||
|
|
||||||
new ComponentAuditedPropertiesReader(
|
new ComponentAuditedPropertiesReader(
|
||||||
ModificationStore.FULL,
|
ModificationStore.FULL,
|
||||||
|
true, // true because the collection is being audited
|
||||||
new AuditedPropertiesReader.ComponentPropertiesSource( reflectionManager, component ),
|
new AuditedPropertiesReader.ComponentPropertiesSource( reflectionManager, component ),
|
||||||
auditData, mainGenerator.getGlobalCfg(), reflectionManager, ""
|
auditData, mainGenerator.getGlobalCfg(), reflectionManager, ""
|
||||||
).read();
|
).read();
|
||||||
|
|
|
@ -111,8 +111,14 @@ public final class AnnotationsMetadataReader {
|
||||||
auditData.setDefaultAudited(true);
|
auditData.setDefaultAudited(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
new AuditedPropertiesReader(defaultStore, new PersistentClassPropertiesSource(xclass), auditData,
|
new AuditedPropertiesReader(
|
||||||
globalCfg, reflectionManager, "").read();
|
defaultStore,
|
||||||
|
auditData.isAudited(),
|
||||||
|
new PersistentClassPropertiesSource(xclass),
|
||||||
|
auditData,
|
||||||
|
globalCfg,
|
||||||
|
reflectionManager, ""
|
||||||
|
).read();
|
||||||
|
|
||||||
addAuditTable(xclass);
|
addAuditTable(xclass);
|
||||||
addAuditSecondaryTables(xclass);
|
addAuditSecondaryTables(xclass);
|
||||||
|
|
|
@ -49,6 +49,7 @@ import static org.hibernate.envers.tools.Tools.newHashSet;
|
||||||
*/
|
*/
|
||||||
public class AuditedPropertiesReader {
|
public class AuditedPropertiesReader {
|
||||||
protected final ModificationStore defaultStore;
|
protected final ModificationStore defaultStore;
|
||||||
|
private final boolean defaultAudited;
|
||||||
private final PersistentPropertiesSource persistentPropertiesSource;
|
private final PersistentPropertiesSource persistentPropertiesSource;
|
||||||
private final AuditedPropertiesHolder auditedPropertiesHolder;
|
private final AuditedPropertiesHolder auditedPropertiesHolder;
|
||||||
private final GlobalConfiguration globalCfg;
|
private final GlobalConfiguration globalCfg;
|
||||||
|
@ -67,12 +68,14 @@ public class AuditedPropertiesReader {
|
||||||
private final Set<XClass> overriddenNotAuditedClasses;
|
private final Set<XClass> overriddenNotAuditedClasses;
|
||||||
|
|
||||||
public AuditedPropertiesReader(ModificationStore defaultStore,
|
public AuditedPropertiesReader(ModificationStore defaultStore,
|
||||||
|
boolean defaultAudited,
|
||||||
PersistentPropertiesSource persistentPropertiesSource,
|
PersistentPropertiesSource persistentPropertiesSource,
|
||||||
AuditedPropertiesHolder auditedPropertiesHolder,
|
AuditedPropertiesHolder auditedPropertiesHolder,
|
||||||
GlobalConfiguration globalCfg,
|
GlobalConfiguration globalCfg,
|
||||||
ReflectionManager reflectionManager,
|
ReflectionManager reflectionManager,
|
||||||
String propertyNamePrefix) {
|
String propertyNamePrefix) {
|
||||||
this.defaultStore = defaultStore;
|
this.defaultStore = defaultStore;
|
||||||
|
this.defaultAudited = defaultAudited;
|
||||||
this.persistentPropertiesSource = persistentPropertiesSource;
|
this.persistentPropertiesSource = persistentPropertiesSource;
|
||||||
this.auditedPropertiesHolder = auditedPropertiesHolder;
|
this.auditedPropertiesHolder = auditedPropertiesHolder;
|
||||||
this.globalCfg = globalCfg;
|
this.globalCfg = globalCfg;
|
||||||
|
@ -276,7 +279,7 @@ public class AuditedPropertiesReader {
|
||||||
addFromProperties(clazz.getDeclaredProperties("field"), "field", fieldAccessedPersistentProperties, allClassAudited);
|
addFromProperties(clazz.getDeclaredProperties("field"), "field", fieldAccessedPersistentProperties, allClassAudited);
|
||||||
addFromProperties(clazz.getDeclaredProperties("property"), "property", propertyAccessedPersistentProperties, allClassAudited);
|
addFromProperties(clazz.getDeclaredProperties("property"), "property", propertyAccessedPersistentProperties, allClassAudited);
|
||||||
|
|
||||||
if(allClassAudited != null || !auditedPropertiesHolder.isEmpty()) {
|
if(allClassAudited != null || !auditedPropertiesHolder.isEmpty() || defaultAudited) {
|
||||||
XClass superclazz = clazz.getSuperclass();
|
XClass superclazz = clazz.getSuperclass();
|
||||||
if (!clazz.isInterface() && !"java.lang.Object".equals(superclazz.getName())) {
|
if (!clazz.isInterface() && !"java.lang.Object".equals(superclazz.getName())) {
|
||||||
addPropertiesFromClass(superclazz);
|
addPropertiesFromClass(superclazz);
|
||||||
|
@ -321,8 +324,8 @@ public class AuditedPropertiesReader {
|
||||||
|
|
||||||
PersistentPropertiesSource componentPropertiesSource = new ComponentPropertiesSource( reflectionManager, propertyValue );
|
PersistentPropertiesSource componentPropertiesSource = new ComponentPropertiesSource( reflectionManager, propertyValue );
|
||||||
AuditedPropertiesReader audPropReader = new AuditedPropertiesReader(
|
AuditedPropertiesReader audPropReader = new AuditedPropertiesReader(
|
||||||
ModificationStore.FULL, componentPropertiesSource, componentData, globalCfg, reflectionManager,
|
ModificationStore.FULL, defaultAudited, componentPropertiesSource, componentData, globalCfg,
|
||||||
propertyNamePrefix + MappingTools.createComponentPrefix(embeddedName)
|
reflectionManager, propertyNamePrefix + MappingTools.createComponentPrefix(embeddedName)
|
||||||
);
|
);
|
||||||
audPropReader.read();
|
audPropReader.read();
|
||||||
|
|
||||||
|
@ -349,7 +352,7 @@ public class AuditedPropertiesReader {
|
||||||
);
|
);
|
||||||
|
|
||||||
ComponentAuditedPropertiesReader audPropReader = new ComponentAuditedPropertiesReader(
|
ComponentAuditedPropertiesReader audPropReader = new ComponentAuditedPropertiesReader(
|
||||||
ModificationStore.FULL, componentPropertiesSource, componentData, globalCfg, reflectionManager,
|
ModificationStore.FULL, isAudited, componentPropertiesSource, componentData, globalCfg, reflectionManager,
|
||||||
propertyNamePrefix + MappingTools.createComponentPrefix( property.getName() )
|
propertyNamePrefix + MappingTools.createComponentPrefix( property.getName() )
|
||||||
);
|
);
|
||||||
audPropReader.read();
|
audPropReader.read();
|
||||||
|
|
|
@ -14,11 +14,12 @@ import org.hibernate.envers.configuration.GlobalConfiguration;
|
||||||
public class ComponentAuditedPropertiesReader extends AuditedPropertiesReader {
|
public class ComponentAuditedPropertiesReader extends AuditedPropertiesReader {
|
||||||
|
|
||||||
public ComponentAuditedPropertiesReader(ModificationStore defaultStore,
|
public ComponentAuditedPropertiesReader(ModificationStore defaultStore,
|
||||||
|
boolean defaultAudited,
|
||||||
PersistentPropertiesSource persistentPropertiesSource,
|
PersistentPropertiesSource persistentPropertiesSource,
|
||||||
AuditedPropertiesHolder auditedPropertiesHolder,
|
AuditedPropertiesHolder auditedPropertiesHolder,
|
||||||
GlobalConfiguration globalCfg, ReflectionManager reflectionManager,
|
GlobalConfiguration globalCfg, ReflectionManager reflectionManager,
|
||||||
String propertyNamePrefix) {
|
String propertyNamePrefix) {
|
||||||
super(defaultStore, persistentPropertiesSource, auditedPropertiesHolder,
|
super(defaultStore, defaultAudited, persistentPropertiesSource, auditedPropertiesHolder,
|
||||||
globalCfg, reflectionManager, propertyNamePrefix);
|
globalCfg, reflectionManager, propertyNamePrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014, Red Hat Inc. or third-party contributors as
|
||||||
|
* indicated by the @author tags or express copyright attribution
|
||||||
|
* statements applied by the authors. All third-party contributions are
|
||||||
|
* distributed under license by Red Hat Inc.
|
||||||
|
*
|
||||||
|
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||||
|
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||||
|
* Lesser General Public License, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this distribution; if not, write to:
|
||||||
|
* Free Software Foundation, Inc.
|
||||||
|
* 51 Franklin Street, Fifth Floor
|
||||||
|
* Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.hibernate.envers.test.integration.components.collections.mappedsuperclasselement;
|
||||||
|
|
||||||
|
import javax.persistence.Access;
|
||||||
|
import javax.persistence.AccessType;
|
||||||
|
import javax.persistence.MappedSuperclass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jakob Braeuchi.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@MappedSuperclass
|
||||||
|
@Access(AccessType.PROPERTY)
|
||||||
|
public abstract class AbstractCode {
|
||||||
|
/**
|
||||||
|
* Initial Value
|
||||||
|
*/
|
||||||
|
protected static final int UNDEFINED = -1;
|
||||||
|
|
||||||
|
private int code = UNDEFINED;
|
||||||
|
|
||||||
|
protected AbstractCode() {
|
||||||
|
this( UNDEFINED );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor with code
|
||||||
|
*/
|
||||||
|
public AbstractCode(int code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(int code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + code;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if ( this == obj ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if ( obj == null ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ( getClass() != obj.getClass() ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
AbstractCode other = (AbstractCode) obj;
|
||||||
|
if ( code != other.code ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014, Red Hat Inc. or third-party contributors as
|
||||||
|
* indicated by the @author tags or express copyright attribution
|
||||||
|
* statements applied by the authors. All third-party contributions are
|
||||||
|
* distributed under license by Red Hat Inc.
|
||||||
|
*
|
||||||
|
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||||
|
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||||
|
* Lesser General Public License, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this distribution; if not, write to:
|
||||||
|
* Free Software Foundation, Inc.
|
||||||
|
* 51 Franklin Street, Fifth Floor
|
||||||
|
* Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.hibernate.envers.test.integration.components.collections.mappedsuperclasselement;
|
||||||
|
|
||||||
|
import javax.persistence.Embeddable;
|
||||||
|
import javax.persistence.Transient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jakob Braeuchi.
|
||||||
|
*/
|
||||||
|
@Embeddable
|
||||||
|
public class Code extends AbstractCode {
|
||||||
|
|
||||||
|
public Code() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Code(int code) {
|
||||||
|
super( code );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,102 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014, Red Hat Middleware LLC or third-party contributors as
|
||||||
|
* indicated by the @author tags or express copyright attribution
|
||||||
|
* statements applied by the authors. All third-party contributions are
|
||||||
|
* distributed under license by Red Hat Middleware LLC.
|
||||||
|
*
|
||||||
|
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||||
|
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||||
|
* Lesser General Public License, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this distribution; if not, write to:
|
||||||
|
* Free Software Foundation, Inc.
|
||||||
|
* 51 Franklin Street, Fifth Floor
|
||||||
|
* Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.hibernate.envers.test.integration.components.collections.mappedsuperclasselement;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
|
||||||
|
import org.hibernate.envers.test.Priority;
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Gail Badner
|
||||||
|
*/
|
||||||
|
@TestForIssue( jiraKey = "HHH-8908" )
|
||||||
|
public class CollectionOfMappedSuperclassComponentsTest extends BaseEnversJPAFunctionalTestCase {
|
||||||
|
private Integer id1;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<?>[] getAnnotatedClasses() {
|
||||||
|
return new Class[] {MappedSuperclassComponentSetTestEntity.class, Code.class};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Priority(10)
|
||||||
|
public void initData() {
|
||||||
|
// Revision 1
|
||||||
|
EntityManager em = getEntityManager();
|
||||||
|
em.getTransaction().begin();
|
||||||
|
|
||||||
|
MappedSuperclassComponentSetTestEntity cte1 = new MappedSuperclassComponentSetTestEntity();
|
||||||
|
|
||||||
|
em.persist( cte1 );
|
||||||
|
|
||||||
|
em.getTransaction().commit();
|
||||||
|
|
||||||
|
// Revision 2
|
||||||
|
em = getEntityManager();
|
||||||
|
em.getTransaction().begin();
|
||||||
|
|
||||||
|
cte1 = em.find( MappedSuperclassComponentSetTestEntity.class, cte1.getId() );
|
||||||
|
|
||||||
|
cte1.getComps().add( new Code( 1 ) );
|
||||||
|
cte1.getCompsNotAudited().add( new Code( 100 ) );
|
||||||
|
|
||||||
|
em.getTransaction().commit();
|
||||||
|
|
||||||
|
id1 = cte1.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRevisionsCounts() {
|
||||||
|
assertEquals(
|
||||||
|
Arrays.asList( 1, 2 ),
|
||||||
|
getAuditReader().getRevisions( MappedSuperclassComponentSetTestEntity.class, id1 )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testHistoryOfId1() {
|
||||||
|
MappedSuperclassComponentSetTestEntity entity = getAuditReader().find(
|
||||||
|
MappedSuperclassComponentSetTestEntity.class,
|
||||||
|
id1,
|
||||||
|
1
|
||||||
|
);
|
||||||
|
assertEquals( 0, entity.getComps().size() );
|
||||||
|
assertEquals( 0, entity.getCompsNotAudited().size() );
|
||||||
|
|
||||||
|
entity = getAuditReader().find( MappedSuperclassComponentSetTestEntity.class, id1, 2 );
|
||||||
|
Set<Code> comps1 = entity.getComps();
|
||||||
|
assertEquals( 1, comps1.size() );
|
||||||
|
assertTrue( comps1.contains( new Code( 1 ) ) );
|
||||||
|
// The contents of entity.getCompsNotAudited() is unspecified, so no need to test.
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,123 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014, Red Hat Middleware LLC or third-party contributors as
|
||||||
|
* indicated by the @author tags or express copyright attribution
|
||||||
|
* statements applied by the authors. All third-party contributions are
|
||||||
|
* distributed under license by Red Hat Middleware LLC.
|
||||||
|
*
|
||||||
|
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||||
|
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||||
|
* Lesser General Public License, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this distribution; if not, write to:
|
||||||
|
* Free Software Foundation, Inc.
|
||||||
|
* 51 Franklin Street, Fifth Floor
|
||||||
|
* Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.hibernate.envers.test.integration.components.collections.mappedsuperclasselement;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.persistence.CollectionTable;
|
||||||
|
import javax.persistence.ElementCollection;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
|
||||||
|
import org.hibernate.envers.Audited;
|
||||||
|
import org.hibernate.envers.NotAudited;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adam Warski (adam at warski dot org)
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Audited
|
||||||
|
public class MappedSuperclassComponentSetTestEntity {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ElementCollection
|
||||||
|
@CollectionTable(name = "MCompTestEntityComps", joinColumns = @JoinColumn(name = "entity_id"))
|
||||||
|
private Set<Code> comps = new HashSet<Code>();
|
||||||
|
|
||||||
|
@NotAudited
|
||||||
|
@ElementCollection
|
||||||
|
@CollectionTable(name = "MCompTestEntityCompsNotAudited", joinColumns = @JoinColumn(name = "entity_id"))
|
||||||
|
private Set<Code> compsNotAudited = new HashSet<Code>();
|
||||||
|
|
||||||
|
public MappedSuperclassComponentSetTestEntity() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public MappedSuperclassComponentSetTestEntity(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Code> getComps() {
|
||||||
|
return comps;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComps(Set<Code> comps) {
|
||||||
|
this.comps = comps;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Code> getCompsNotAudited() {
|
||||||
|
return compsNotAudited;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCompsNotAudited(Set<Code> comps) {
|
||||||
|
this.compsNotAudited = compsNotAudited;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if ( this == o ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if ( !(o instanceof MappedSuperclassComponentSetTestEntity ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
MappedSuperclassComponentSetTestEntity that = (MappedSuperclassComponentSetTestEntity) o;
|
||||||
|
|
||||||
|
if ( comps != null ? !comps.equals( that.comps ) : that.comps != null ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ( id != null ? !id.equals( that.id ) : that.id != null ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = id != null ? id.hashCode() : 0;
|
||||||
|
result = 31 * result + (comps != null ? comps.hashCode() : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ComponentSetTestEntity{" +
|
||||||
|
"id=" + id +
|
||||||
|
", comps=" + comps +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014, Red Hat Inc. or third-party contributors as
|
||||||
|
* indicated by the @author tags or express copyright attribution
|
||||||
|
* statements applied by the authors. All third-party contributions are
|
||||||
|
* distributed under license by Red Hat Inc.
|
||||||
|
*
|
||||||
|
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||||
|
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||||
|
* Lesser General Public License, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this distribution; if not, write to:
|
||||||
|
* Free Software Foundation, Inc.
|
||||||
|
* 51 Franklin Street, Fifth Floor
|
||||||
|
* Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.hibernate.envers.test.integration.components.mappedsuperclass;
|
||||||
|
|
||||||
|
import javax.persistence.Access;
|
||||||
|
import javax.persistence.AccessType;
|
||||||
|
import javax.persistence.MappedSuperclass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jakob Braeuchi.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@MappedSuperclass
|
||||||
|
@Access(AccessType.FIELD)
|
||||||
|
public abstract class AbstractEmbeddable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initial Value
|
||||||
|
*/
|
||||||
|
protected static final int UNDEFINED = -1;
|
||||||
|
|
||||||
|
private int code = UNDEFINED;
|
||||||
|
|
||||||
|
|
||||||
|
protected AbstractEmbeddable() {
|
||||||
|
this( UNDEFINED );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor with code
|
||||||
|
*/
|
||||||
|
public AbstractEmbeddable(int code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + code;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if ( this == obj ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if ( obj == null ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ( getClass() != obj.getClass() ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
AbstractEmbeddable other = (AbstractEmbeddable) obj;
|
||||||
|
if ( code != other.code ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,83 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014, Red Hat Inc. or third-party contributors as
|
||||||
|
* indicated by the @author tags or express copyright attribution
|
||||||
|
* statements applied by the authors. All third-party contributions are
|
||||||
|
* distributed under license by Red Hat Inc.
|
||||||
|
*
|
||||||
|
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||||
|
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||||
|
* Lesser General Public License, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this distribution; if not, write to:
|
||||||
|
* Free Software Foundation, Inc.
|
||||||
|
* 51 Franklin Street, Fifth Floor
|
||||||
|
* Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.hibernate.envers.test.integration.components.mappedsuperclass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jakob Braeuchi.
|
||||||
|
* @author Gail Badner
|
||||||
|
*/
|
||||||
|
|
||||||
|
import javax.persistence.Embeddable;
|
||||||
|
|
||||||
|
@Embeddable
|
||||||
|
public class EmbeddableWithDeclaredData extends AbstractEmbeddable {
|
||||||
|
|
||||||
|
private String codeArt;
|
||||||
|
|
||||||
|
public EmbeddableWithDeclaredData(int code, String codeArt) {
|
||||||
|
super( code );
|
||||||
|
this.codeArt = codeArt;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Needed for @Embeddable
|
||||||
|
protected EmbeddableWithDeclaredData() {
|
||||||
|
this( UNDEFINED, null );
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCodeart() {
|
||||||
|
return codeArt;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = super.hashCode();
|
||||||
|
result = prime * result + ( ( codeArt == null ) ? 0 : codeArt.hashCode() );
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if ( this == obj ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if ( !super.equals( obj ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ( getClass() != obj.getClass() ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
EmbeddableWithDeclaredData other = (EmbeddableWithDeclaredData) obj;
|
||||||
|
if ( codeArt == null ) {
|
||||||
|
if ( other.codeArt != null ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( !codeArt.equals( other.codeArt ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014, Red Hat Inc. or third-party contributors as
|
||||||
|
* indicated by the @author tags or express copyright attribution
|
||||||
|
* statements applied by the authors. All third-party contributions are
|
||||||
|
* distributed under license by Red Hat Inc.
|
||||||
|
*
|
||||||
|
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||||
|
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||||
|
* Lesser General Public License, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this distribution; if not, write to:
|
||||||
|
* Free Software Foundation, Inc.
|
||||||
|
* 51 Franklin Street, Fifth Floor
|
||||||
|
* Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.hibernate.envers.test.integration.components.mappedsuperclass;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.persistence.EntityTransaction;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import org.hibernate.envers.AuditReader;
|
||||||
|
import org.hibernate.envers.AuditReaderFactory;
|
||||||
|
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
|
||||||
|
import org.hibernate.envers.test.Priority;
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jakob Braeuchi.
|
||||||
|
* @author Gail Badner
|
||||||
|
*/
|
||||||
|
@TestForIssue(jiraKey = "HHH-8908")
|
||||||
|
public class EmbeddableWithDeclaredDataTest extends BaseEnversJPAFunctionalTestCase {
|
||||||
|
private long id;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<?>[] getAnnotatedClasses() {
|
||||||
|
return new Class[] { EntityWithEmbeddableWithDeclaredData.class, AbstractEmbeddable.class, EmbeddableWithDeclaredData.class };
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Priority(10)
|
||||||
|
public void initData() {
|
||||||
|
EntityManager em = getEntityManager();
|
||||||
|
|
||||||
|
EntityWithEmbeddableWithDeclaredData entity = new EntityWithEmbeddableWithDeclaredData();
|
||||||
|
entity.setName( "Entity 1" );
|
||||||
|
entity.setValue( new EmbeddableWithDeclaredData( 42, "TestCodeart" ) );
|
||||||
|
|
||||||
|
EntityTransaction tx = em.getTransaction();
|
||||||
|
tx.begin();
|
||||||
|
em.persist( entity );
|
||||||
|
tx.commit();
|
||||||
|
em.close();
|
||||||
|
|
||||||
|
id = entity.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEmbeddableThatExtendsMappedSuperclass() {
|
||||||
|
|
||||||
|
// Reload and Compare Revision
|
||||||
|
EntityManager em = getEntityManager();
|
||||||
|
EntityWithEmbeddableWithDeclaredData entityLoaded = em.find( EntityWithEmbeddableWithDeclaredData.class, id );
|
||||||
|
|
||||||
|
AuditReader reader = AuditReaderFactory.get( em );
|
||||||
|
|
||||||
|
List<Number> revs = reader.getRevisions( EntityWithEmbeddableWithDeclaredData.class, id );
|
||||||
|
Assert.assertEquals( 1, revs.size() );
|
||||||
|
|
||||||
|
EntityWithEmbeddableWithDeclaredData entityRev1 = reader.find( EntityWithEmbeddableWithDeclaredData.class, id, revs.get( 0 ) );
|
||||||
|
|
||||||
|
Assert.assertEquals( entityLoaded.getName(), entityRev1.getName() );
|
||||||
|
|
||||||
|
// value is read from AUD Table
|
||||||
|
Assert.assertEquals( entityLoaded.getValue(), entityRev1.getValue() );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014, Red Hat Inc. or third-party contributors as
|
||||||
|
* indicated by the @author tags or express copyright attribution
|
||||||
|
* statements applied by the authors. All third-party contributions are
|
||||||
|
* distributed under license by Red Hat Inc.
|
||||||
|
*
|
||||||
|
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||||
|
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||||
|
* Lesser General Public License, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this distribution; if not, write to:
|
||||||
|
* Free Software Foundation, Inc.
|
||||||
|
* 51 Franklin Street, Fifth Floor
|
||||||
|
* Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.hibernate.envers.test.integration.components.mappedsuperclass;
|
||||||
|
|
||||||
|
import javax.persistence.Embeddable;
|
||||||
|
import javax.persistence.Transient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jakob Braeuchi.
|
||||||
|
* @author Gail Badner
|
||||||
|
*/
|
||||||
|
@Embeddable
|
||||||
|
public class EmbeddableWithNoDeclaredData extends AbstractEmbeddable {
|
||||||
|
|
||||||
|
public EmbeddableWithNoDeclaredData(int code) {
|
||||||
|
super( code );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Needed for @Embeddable
|
||||||
|
protected EmbeddableWithNoDeclaredData() {
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014, Red Hat Inc. or third-party contributors as
|
||||||
|
* indicated by the @author tags or express copyright attribution
|
||||||
|
* statements applied by the authors. All third-party contributions are
|
||||||
|
* distributed under license by Red Hat Inc.
|
||||||
|
*
|
||||||
|
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||||
|
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||||
|
* Lesser General Public License, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this distribution; if not, write to:
|
||||||
|
* Free Software Foundation, Inc.
|
||||||
|
* 51 Franklin Street, Fifth Floor
|
||||||
|
* Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.hibernate.envers.test.integration.components.mappedsuperclass;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.persistence.EntityTransaction;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import org.hibernate.envers.AuditReader;
|
||||||
|
import org.hibernate.envers.AuditReaderFactory;
|
||||||
|
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
|
||||||
|
import org.hibernate.envers.test.Priority;
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jakob Braeuchi.
|
||||||
|
* @author Gail Badner
|
||||||
|
*/
|
||||||
|
@TestForIssue(jiraKey = "HHH-8908")
|
||||||
|
public class EmbeddableWithNoDeclaredDataTest extends BaseEnversJPAFunctionalTestCase {
|
||||||
|
private long id;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<?>[] getAnnotatedClasses() {
|
||||||
|
return new Class[] { EntityWithEmbeddableWithNoDeclaredData.class, AbstractEmbeddable.class, EmbeddableWithNoDeclaredData.class };
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Priority(10)
|
||||||
|
public void initData() {
|
||||||
|
EntityManager em = getEntityManager();
|
||||||
|
|
||||||
|
EntityWithEmbeddableWithNoDeclaredData entity = new EntityWithEmbeddableWithNoDeclaredData();
|
||||||
|
entity.setName( "Entity 1" );
|
||||||
|
entity.setValue( new EmbeddableWithNoDeclaredData( 84 ) );
|
||||||
|
|
||||||
|
EntityTransaction tx = em.getTransaction();
|
||||||
|
tx.begin();
|
||||||
|
em.persist( entity );
|
||||||
|
tx.commit();
|
||||||
|
em.close();
|
||||||
|
|
||||||
|
id = entity.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEmbeddableThatExtendsMappedSuperclass() {
|
||||||
|
|
||||||
|
// Reload and Compare Revision
|
||||||
|
EntityManager em = getEntityManager();
|
||||||
|
EntityWithEmbeddableWithNoDeclaredData entityLoaded = em.find( EntityWithEmbeddableWithNoDeclaredData.class, id );
|
||||||
|
|
||||||
|
AuditReader reader = AuditReaderFactory.get( em );
|
||||||
|
|
||||||
|
List<Number> revs = reader.getRevisions( EntityWithEmbeddableWithNoDeclaredData.class, id );
|
||||||
|
Assert.assertEquals( 1, revs.size() );
|
||||||
|
|
||||||
|
EntityWithEmbeddableWithNoDeclaredData entityRev1 = reader.find( EntityWithEmbeddableWithNoDeclaredData.class, id, revs.get( 0 ) );
|
||||||
|
|
||||||
|
Assert.assertEquals( entityLoaded.getName(), entityRev1.getName() );
|
||||||
|
|
||||||
|
// value is read from AUD Table
|
||||||
|
Assert.assertEquals( entityLoaded.getValue(), entityRev1.getValue() );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,104 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014, Red Hat Inc. or third-party contributors as
|
||||||
|
* indicated by the @author tags or express copyright attribution
|
||||||
|
* statements applied by the authors. All third-party contributions are
|
||||||
|
* distributed under license by Red Hat Inc.
|
||||||
|
*
|
||||||
|
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||||
|
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||||
|
* Lesser General Public License, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this distribution; if not, write to:
|
||||||
|
* Free Software Foundation, Inc.
|
||||||
|
* 51 Franklin Street, Fifth Floor
|
||||||
|
* Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.hibernate.envers.test.integration.components.mappedsuperclass;
|
||||||
|
|
||||||
|
|
||||||
|
import javax.persistence.Access;
|
||||||
|
import javax.persistence.AccessType;
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Embedded;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
|
||||||
|
import org.hibernate.envers.Audited;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jakob Braeuchi.
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Access(AccessType.FIELD)
|
||||||
|
@Audited
|
||||||
|
public class EntityWithEmbeddableWithDeclaredData {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
|
private long id;
|
||||||
|
|
||||||
|
@Column(name = "NAME", length = 100)
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Embedded
|
||||||
|
private EmbeddableWithDeclaredData value;
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmbeddableWithDeclaredData getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(EmbeddableWithDeclaredData value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + (int) ( id ^ ( id >>> 32 ) );
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if ( this == obj ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if ( obj == null ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ( getClass() != obj.getClass() ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
EntityWithEmbeddableWithDeclaredData other = (EntityWithEmbeddableWithDeclaredData) obj;
|
||||||
|
if ( id != other.id ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,104 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014, Red Hat Inc. or third-party contributors as
|
||||||
|
* indicated by the @author tags or express copyright attribution
|
||||||
|
* statements applied by the authors. All third-party contributions are
|
||||||
|
* distributed under license by Red Hat Inc.
|
||||||
|
*
|
||||||
|
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||||
|
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||||
|
* Lesser General Public License, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this distribution; if not, write to:
|
||||||
|
* Free Software Foundation, Inc.
|
||||||
|
* 51 Franklin Street, Fifth Floor
|
||||||
|
* Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.hibernate.envers.test.integration.components.mappedsuperclass;
|
||||||
|
|
||||||
|
|
||||||
|
import javax.persistence.Access;
|
||||||
|
import javax.persistence.AccessType;
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Embedded;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
|
||||||
|
import org.hibernate.envers.Audited;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jakob Braeuchi.
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Access(AccessType.FIELD)
|
||||||
|
@Audited
|
||||||
|
public class EntityWithEmbeddableWithNoDeclaredData {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
|
private long id;
|
||||||
|
|
||||||
|
@Column(name = "NAME", length = 100)
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Embedded
|
||||||
|
private EmbeddableWithNoDeclaredData value;
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmbeddableWithNoDeclaredData getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(EmbeddableWithNoDeclaredData value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + (int) ( id ^ ( id >>> 32 ) );
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if ( this == obj ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if ( obj == null ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ( getClass() != obj.getClass() ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
EntityWithEmbeddableWithNoDeclaredData other = (EntityWithEmbeddableWithNoDeclaredData) obj;
|
||||||
|
if ( id != other.id ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue