HHH-14220 Add test for issue
This commit is contained in:
parent
ad80d0bb41
commit
5b8f5aa756
|
@ -7,6 +7,7 @@
|
|||
package org.hibernate.test.bytecode.enhancement.lazy.proxy.inlinedirtychecking;
|
||||
|
||||
import org.hibernate.bytecode.enhance.spi.UnloadedClass;
|
||||
import org.hibernate.bytecode.enhance.spi.UnloadedField;
|
||||
|
||||
import org.hibernate.testing.bytecode.enhancement.EnhancerTestContext;
|
||||
|
||||
|
@ -18,4 +19,9 @@ public class DirtyCheckEnhancementContext extends EnhancerTestContext {
|
|||
public boolean doExtendedEnhancement(UnloadedClass classDescriptor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doBiDirectionalAssociationManagement(UnloadedField field) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* 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.test.bytecode.enhancement.lazy.proxy.inlinedirtychecking;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.Convert;
|
||||
import javax.persistence.Converter;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
|
||||
import org.hibernate.boot.MetadataSources;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
|
||||
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
|
||||
import org.hibernate.testing.bytecode.enhancement.CustomEnhancementContext;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
@RunWith(BytecodeEnhancerRunner.class)
|
||||
@CustomEnhancementContext({ DirtyCheckEnhancementContext.class })
|
||||
public class DirtyCheckPrivateUnMappedCollectionTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
@Override
|
||||
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
|
||||
super.configureStandardServiceRegistryBuilder( ssrb );
|
||||
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
|
||||
ssrb.applySetting( AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, "100" );
|
||||
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyMetadataSources(MetadataSources sources) {
|
||||
sources.addAnnotatedClass( Measurement.class );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIt() {
|
||||
inTransaction(
|
||||
session -> {
|
||||
Tag tag = new Tag();
|
||||
tag.setName( "tag1" );
|
||||
|
||||
Measurement measurementDescriptor = new Measurement();
|
||||
measurementDescriptor.addTag( tag );
|
||||
|
||||
session.save( measurementDescriptor );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@MappedSuperclass
|
||||
public static class AbstractMeasurement {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
@Convert(converter = TagAttributeConverter.class)
|
||||
private List<Tag> tags = new ArrayList<>();
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<Tag> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(List<Tag> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public void addTag(Tag tag) {
|
||||
this.tags.add( tag );
|
||||
}
|
||||
}
|
||||
|
||||
@Entity
|
||||
public static class Measurement extends AbstractMeasurement {
|
||||
}
|
||||
|
||||
public static class Tag {
|
||||
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
@Converter
|
||||
public static class TagAttributeConverter implements AttributeConverter<List<Tag>, String> {
|
||||
|
||||
@Override
|
||||
public String convertToDatabaseColumn(List<Tag> attribute) {
|
||||
return "empty";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Tag> convertToEntityAttribute(String dbData) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -7,13 +7,14 @@
|
|||
package org.hibernate.test.bytecode.enhancement.lazy.proxy.inlinedirtychecking;
|
||||
|
||||
import org.hibernate.bytecode.enhance.spi.UnloadedClass;
|
||||
import org.hibernate.bytecode.enhance.spi.UnloadedField;
|
||||
|
||||
import org.hibernate.testing.bytecode.enhancement.EnhancerTestContext;
|
||||
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
public class NoDirtyCheckEnhancementContext extends EnhancerTestContext {
|
||||
public class NoDirtyCheckEnhancementContext extends EnhancerTestContext {
|
||||
@Override
|
||||
public boolean doDirtyCheckingInline(UnloadedClass classDescriptor) {
|
||||
return false;
|
||||
|
@ -23,4 +24,9 @@ public class NoDirtyCheckEnhancementContext extends EnhancerTestContext {
|
|||
public boolean doExtendedEnhancement(UnloadedClass classDescriptor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doBiDirectionalAssociationManagement(UnloadedField field) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue