HHH-12085 - @NaturalId not working on inherited field
This commit is contained in:
parent
e9263758fe
commit
7c57d11406
|
@ -6,62 +6,36 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.naturalid.inheritance;
|
package org.hibernate.test.naturalid.inheritance;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.MappedSuperclass;
|
import javax.persistence.MappedSuperclass;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.annotations.Cache;
|
import org.hibernate.annotations.NaturalId;
|
||||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
|
||||||
import org.hibernate.annotations.NaturalIdCache;
|
|
||||||
import org.hibernate.boot.MetadataSources;
|
import org.hibernate.boot.MetadataSources;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.FailureExpected;
|
||||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
@TestForIssue( jiraKey = "HHH-12085" )
|
@FailureExpected( jiraKey = "HHH-12085" )
|
||||||
public class MappedSuperclassOverrideTest extends BaseNonConfigCoreFunctionalTestCase {
|
public class MappedSuperclassOverrideTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testModel() {
|
||||||
createTestData();
|
assertTrue(
|
||||||
|
sessionFactory().getMetamodel().entityPersister( MyEntity.class )
|
||||||
try {
|
.hasNaturalIdentifier()
|
||||||
inTransaction(
|
|
||||||
session -> session.createQuery( "select e from MyEntity e" ).list()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
dropTestData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createTestData() {
|
|
||||||
inTransaction(
|
|
||||||
session -> {
|
|
||||||
session.save( new MyEntity( 1, "first" ) );
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void dropTestData() {
|
|
||||||
inTransaction(
|
|
||||||
session -> {
|
|
||||||
session.createQuery( "delete MyEntity" ).executeUpdate();
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void addSettings(Map settings) {
|
protected boolean createSchema() {
|
||||||
super.addSettings( settings );
|
return false;
|
||||||
settings.put( AvailableSettings.USE_SECOND_LEVEL_CACHE, "true" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -104,8 +78,6 @@ public class MappedSuperclassOverrideTest extends BaseNonConfigCoreFunctionalTes
|
||||||
|
|
||||||
@Entity( name = "MyEntity" )
|
@Entity( name = "MyEntity" )
|
||||||
@Table( name = "the_entity" )
|
@Table( name = "the_entity" )
|
||||||
@NaturalIdCache
|
|
||||||
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
|
||||||
public static class MyEntity extends MyMappedSuperclass {
|
public static class MyEntity extends MyMappedSuperclass {
|
||||||
public MyEntity() {
|
public MyEntity() {
|
||||||
super();
|
super();
|
||||||
|
@ -117,6 +89,7 @@ public class MappedSuperclassOverrideTest extends BaseNonConfigCoreFunctionalTes
|
||||||
|
|
||||||
// this should not be allowed, and supposedly fails anyway...
|
// this should not be allowed, and supposedly fails anyway...
|
||||||
@Override
|
@Override
|
||||||
|
@NaturalId
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return super.getName();
|
return super.getName();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue