HHH-12199 - Added test case.
This commit is contained in:
parent
6fb4ec0e02
commit
b44001c644
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!--
|
||||||
|
~ 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>.
|
||||||
|
-->
|
||||||
|
<!DOCTYPE hibernate-mapping PUBLIC
|
||||||
|
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||||
|
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||||
|
|
||||||
|
<hibernate-mapping>
|
||||||
|
<class name="org.hibernate.test.cfg.PropertyAccessTypeDetectionType$FooEntity" table="foo_entity">
|
||||||
|
<id name="id" type="long">
|
||||||
|
<generator class="native" />
|
||||||
|
</id>
|
||||||
|
<property name="intValue" />
|
||||||
|
</class>
|
||||||
|
</hibernate-mapping>
|
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* 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.cfg;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Chris Cranford
|
||||||
|
*/
|
||||||
|
@TestForIssue(jiraKey ="HHH-12199")
|
||||||
|
public class PropertyAccessTypeDetectionType extends BaseCoreFunctionalTestCase {
|
||||||
|
@Override
|
||||||
|
protected String[] getMappings() {
|
||||||
|
return new String[] { "cfg/FooEntity.hbm.xml" };
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class FooEntity {
|
||||||
|
public static final String intValue = "intValue";
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private Integer _intValue;
|
||||||
|
|
||||||
|
public Long getId() { return id; }
|
||||||
|
public void setId(Long id) { this.id = id; }
|
||||||
|
|
||||||
|
public Integer getIntValue() { return _intValue; }
|
||||||
|
public void setIntValue(Integer intValue) { this._intValue = intValue; }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void testPropertyAccessIgnoresStaticFields() {
|
||||||
|
// verify that the entity persister is configured with property intValue as an Integer rather than
|
||||||
|
// using the static field reference and determining the type to be String.
|
||||||
|
assertTrue(
|
||||||
|
sessionFactory()
|
||||||
|
.getMetamodel()
|
||||||
|
.entityPersister( FooEntity.class )
|
||||||
|
.getPropertyType( "intValue" )
|
||||||
|
.getReturnedClass()
|
||||||
|
.isAssignableFrom( Integer.class )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue