mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-09 04:34:49 +00:00
HHH-11078 - Attribute in metamodel is null for overridden property
- Add replicating test case
This commit is contained in:
parent
dd895c78b6
commit
0794e103d7
@ -6,18 +6,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.jpa.test.metagen.mappedsuperclass.attribute;
|
package org.hibernate.jpa.test.metagen.mappedsuperclass.attribute;
|
||||||
|
|
||||||
import javax.persistence.EntityManagerFactory;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import javax.persistence.EntityManagerFactory;
|
||||||
|
|
||||||
import org.hibernate.jpa.test.TestingEntityManagerFactoryGenerator;
|
|
||||||
import org.hibernate.jpa.test.metagen.mappedsuperclass.attribute.AbstractNameable_;
|
|
||||||
import org.hibernate.jpa.test.metagen.mappedsuperclass.attribute.Product_;
|
|
||||||
import org.hibernate.jpa.AvailableSettings;
|
import org.hibernate.jpa.AvailableSettings;
|
||||||
|
import org.hibernate.jpa.test.TestingEntityManagerFactoryGenerator;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* 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.jpa.test.metagen.mappedsuperclass.overridden;
|
||||||
|
|
||||||
|
import javax.persistence.Access;
|
||||||
|
import javax.persistence.AccessType;
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.MappedSuperclass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Oliver Breidenbach
|
||||||
|
*/
|
||||||
|
@MappedSuperclass
|
||||||
|
@Access(AccessType.PROPERTY)
|
||||||
|
public abstract class AbstractProduct {
|
||||||
|
private Long id;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
protected AbstractProduct() {
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AbstractProduct(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
@Id
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
@Column(name = "name")
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* 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.jpa.test.metagen.mappedsuperclass.overridden;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import javax.persistence.EntityManagerFactory;
|
||||||
|
|
||||||
|
import org.hibernate.jpa.AvailableSettings;
|
||||||
|
import org.hibernate.jpa.test.TestingEntityManagerFactoryGenerator;
|
||||||
|
|
||||||
|
import org.hibernate.testing.FailureExpected;
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Oliver Breidenbach
|
||||||
|
*/
|
||||||
|
@TestForIssue(jiraKey = "HHH-11078")
|
||||||
|
public class MappedSuperclassWithOverriddenAttributeTest
|
||||||
|
extends BaseUnitTestCase {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@FailureExpected(jiraKey = "HHH-11078")
|
||||||
|
public void testStaticMetamodelOverridden() {
|
||||||
|
EntityManagerFactory emf = TestingEntityManagerFactoryGenerator.generateEntityManagerFactory(
|
||||||
|
AvailableSettings.LOADED_CLASSES,
|
||||||
|
Arrays.asList( Product2.class )
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
assertNotNull(
|
||||||
|
"'Product1_.overridenName' should not be null)",
|
||||||
|
Product1_.overridenName
|
||||||
|
);
|
||||||
|
|
||||||
|
assertNotNull(
|
||||||
|
"'Product2_.overridenName' should not be null)",
|
||||||
|
Product2_.overridenName
|
||||||
|
); // is null
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
emf.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* 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.jpa.test.metagen.mappedsuperclass.overridden;
|
||||||
|
|
||||||
|
import javax.persistence.Access;
|
||||||
|
import javax.persistence.AccessType;
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Oliver Breidenbach
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name = "product")
|
||||||
|
@Access(AccessType.PROPERTY)
|
||||||
|
public class Product1 extends AbstractProduct {
|
||||||
|
|
||||||
|
private String overridenName;
|
||||||
|
|
||||||
|
public Product1() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Product1(String name) {
|
||||||
|
super( name );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Column(name = "overridenName")
|
||||||
|
public String getOverridenName() {
|
||||||
|
return overridenName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOverridenName(String overridenName) {
|
||||||
|
this.overridenName = overridenName;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* 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.jpa.test.metagen.mappedsuperclass.overridden;
|
||||||
|
|
||||||
|
import javax.persistence.Access;
|
||||||
|
import javax.persistence.AccessType;
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Oliver Breidenbach
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Access(AccessType.PROPERTY)
|
||||||
|
public class Product2 extends Product1 {
|
||||||
|
|
||||||
|
@Column(name = "overridenName"/*, insertable = false, updatable = false*/)
|
||||||
|
public String getOverridenName() {
|
||||||
|
return super.getOverridenName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOverridenName(String overridenName) {
|
||||||
|
super.setOverridenName(overridenName);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user