HHH-15141 Test bytecode enhancement on cross-package inheritance tree with protected @Embedded field
This commit is contained in:
parent
06a95721ea
commit
527103d8b9
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.bytecode.enhancement.lazy.proxy.crosspackage;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.hibernate.orm.test.bytecode.enhancement.lazy.proxy.crosspackage.base.EmbeddableType;
|
||||
import org.hibernate.orm.test.bytecode.enhancement.lazy.proxy.crosspackage.derived.TestEntity;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
|
||||
import org.hibernate.testing.bytecode.enhancement.EnhancementOptions;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(BytecodeEnhancerRunner.class)
|
||||
@EnhancementOptions(lazyLoading = true, inlineDirtyChecking = true)
|
||||
public class CrossPackageMappedSuperclassWithEmbeddableTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
@Override
|
||||
public Class<?>[] getAnnotatedClasses() {
|
||||
return new Class<?>[] { TestEntity.class };
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-15141")
|
||||
public void testIt() {
|
||||
// Just a smoke test; the original failure happened during bytecode enhancement.
|
||||
Long id = fromTransaction( s -> {
|
||||
TestEntity testEntity = new TestEntity();
|
||||
EmbeddableType embedded = new EmbeddableType();
|
||||
embedded.setField( "someValue" );
|
||||
testEntity.setEmbeddedField( embedded );
|
||||
s.persist( testEntity );
|
||||
return testEntity.getId();
|
||||
} );
|
||||
inTransaction( s -> {
|
||||
TestEntity testEntity = s.find( TestEntity.class, id );
|
||||
assertThat( testEntity.getEmbeddedField().getField() ).isEqualTo( "someValue" );
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package org.hibernate.orm.test.bytecode.enhancement.lazy.proxy.crosspackage.base;
|
||||
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
|
||||
@MappedSuperclass
|
||||
public abstract class BaseEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@Embedded
|
||||
protected EmbeddableType embeddedField;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(final Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public EmbeddableType getEmbeddedField() {
|
||||
return embeddedField;
|
||||
}
|
||||
|
||||
public void setEmbeddedField(final EmbeddableType embeddedField) {
|
||||
this.embeddedField = embeddedField;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package org.hibernate.orm.test.bytecode.enhancement.lazy.proxy.crosspackage.base;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embeddable;
|
||||
|
||||
@Embeddable
|
||||
public class EmbeddableType {
|
||||
|
||||
@Column
|
||||
private String field;
|
||||
|
||||
public String getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
public void setField(final String field) {
|
||||
this.field = field;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package org.hibernate.orm.test.bytecode.enhancement.lazy.proxy.crosspackage.derived;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
import org.hibernate.orm.test.bytecode.enhancement.lazy.proxy.crosspackage.base.BaseEntity;
|
||||
|
||||
@Entity
|
||||
public class TestEntity extends BaseEntity {
|
||||
|
||||
}
|
Loading…
Reference in New Issue