parent
7c7c65f42e
commit
612e795ad2
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* 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.entities.manytoone.unidirectional;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.envers.Audited;
|
||||
import org.hibernate.envers.test.entities.UnversionedStrTestEntity;
|
||||
|
||||
/**
|
||||
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "EM2O_N_AUD_NULL")
|
||||
public class ExtManyToOneNotAuditedNullEntity extends ManyToOneNotAuditedNullEntity {
|
||||
@Audited
|
||||
private String extension = null;
|
||||
|
||||
public ExtManyToOneNotAuditedNullEntity() {
|
||||
}
|
||||
|
||||
public ExtManyToOneNotAuditedNullEntity(Integer id, String data, UnversionedStrTestEntity reference, String extension) {
|
||||
super( id, data, reference );
|
||||
this.extension = extension;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) return true;
|
||||
if ( !( o instanceof ExtManyToOneNotAuditedNullEntity ) ) return false;
|
||||
if ( !super.equals( o ) ) return false;
|
||||
|
||||
ExtManyToOneNotAuditedNullEntity that = (ExtManyToOneNotAuditedNullEntity) o;
|
||||
|
||||
if ( extension != null ? !extension.equals( that.extension ) : that.extension != null ) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + (extension != null ? extension.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ExtManyToOneNotAuditedNullEntity(" + super.toString() + ", extension = " + extension + ")";
|
||||
}
|
||||
|
||||
public String getExtension() {
|
||||
return extension;
|
||||
}
|
||||
|
||||
public void setExtension(String extension) {
|
||||
this.extension = extension;
|
||||
}
|
||||
}
|
|
@ -27,6 +27,8 @@ import java.io.Serializable;
|
|||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
|
@ -42,6 +44,7 @@ import org.hibernate.envers.test.entities.UnversionedStrTestEntity;
|
|||
@Audited
|
||||
@Entity
|
||||
@Table(name = "M2O_N_AUD_NULL")
|
||||
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
|
||||
public class ManyToOneNotAuditedNullEntity implements Serializable {
|
||||
@Id
|
||||
private Integer id;
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
|
|||
import org.hibernate.envers.test.Priority;
|
||||
import org.hibernate.envers.test.entities.UnversionedStrTestEntity;
|
||||
import org.hibernate.envers.test.entities.manytomany.unidirectional.ManyToManyNotAuditedNullEntity;
|
||||
import org.hibernate.envers.test.entities.manytoone.unidirectional.ExtManyToOneNotAuditedNullEntity;
|
||||
import org.hibernate.envers.test.entities.manytoone.unidirectional.ManyToOneNotAuditedNullEntity;
|
||||
import org.hibernate.envers.test.entities.manytoone.unidirectional.TargetNotAuditedEntity;
|
||||
import org.hibernate.envers.test.entities.onetomany.OneToManyNotAuditedNullEntity;
|
||||
|
@ -45,6 +46,7 @@ import org.hibernate.testing.TestForIssue;
|
|||
public class ProxyIdentifier extends BaseEnversJPAFunctionalTestCase {
|
||||
private TargetNotAuditedEntity tnae1 = null;
|
||||
private ManyToOneNotAuditedNullEntity mtonane1 = null;
|
||||
private ExtManyToOneNotAuditedNullEntity emtonane1 = null;
|
||||
private ManyToManyNotAuditedNullEntity mtmnane1 = null;
|
||||
private OneToManyNotAuditedNullEntity otmnane1 = null;
|
||||
private UnversionedStrTestEntity uste1 = null;
|
||||
|
@ -54,7 +56,8 @@ public class ProxyIdentifier extends BaseEnversJPAFunctionalTestCase {
|
|||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class[] {
|
||||
TargetNotAuditedEntity.class, ManyToOneNotAuditedNullEntity.class, UnversionedStrTestEntity.class,
|
||||
ManyToManyNotAuditedNullEntity.class, OneToManyNotAuditedNullEntity.class
|
||||
ManyToManyNotAuditedNullEntity.class, OneToManyNotAuditedNullEntity.class,
|
||||
ExtManyToOneNotAuditedNullEntity.class
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -87,9 +90,11 @@ public class ProxyIdentifier extends BaseEnversJPAFunctionalTestCase {
|
|||
mtmnane1.getReferences().add( uste2 );
|
||||
otmnane1 = new OneToManyNotAuditedNullEntity( 4, "otmnane1" );
|
||||
otmnane1.getReferences().add( uste2 );
|
||||
emtonane1 = new ExtManyToOneNotAuditedNullEntity( 5, "emtonane1", uste2, "extension" );
|
||||
em.persist( mtonane1 );
|
||||
em.persist( mtmnane1 );
|
||||
em.persist( otmnane1 );
|
||||
em.persist( emtonane1 );
|
||||
em.getTransaction().commit();
|
||||
|
||||
em.clear();
|
||||
|
@ -107,6 +112,9 @@ public class ProxyIdentifier extends BaseEnversJPAFunctionalTestCase {
|
|||
OneToManyNotAuditedNullEntity tmp3 = em.find( OneToManyNotAuditedNullEntity.class, otmnane1.getId() );
|
||||
tmp3.setReferences( null );
|
||||
tmp3 = em.merge( tmp3 );
|
||||
ExtManyToOneNotAuditedNullEntity tmp4 = em.find( ExtManyToOneNotAuditedNullEntity.class, emtonane1.getId() );
|
||||
tmp4.setReference( null );
|
||||
tmp4 = em.merge( tmp4 );
|
||||
em.remove( em.getReference( UnversionedStrTestEntity.class, uste2.getId() ) );
|
||||
em.getTransaction().commit();
|
||||
|
||||
|
@ -147,4 +155,12 @@ public class ProxyIdentifier extends BaseEnversJPAFunctionalTestCase {
|
|||
Assert.assertEquals( otmnane1, otmRev2 );
|
||||
Assert.assertTrue( otmRev2.getReferences().isEmpty() );
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-8912" )
|
||||
public void testNullReferenceWithNotFoundActionIgnoreInParent() {
|
||||
ExtManyToOneNotAuditedNullEntity emtoRev2 = getAuditReader().find( ExtManyToOneNotAuditedNullEntity.class, emtonane1.getId(), 2 );
|
||||
Assert.assertEquals( emtonane1, emtoRev2 );
|
||||
Assert.assertNull( emtoRev2.getReference() );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue