Skip to content

Commit d47e9da

Browse files
committed
HHH-8689 regression test
1 parent c418ea1 commit d47e9da

File tree

3 files changed

+127
-0
lines changed

3 files changed

+127
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* Copyright (c) 2006-2011, Red Hat Inc. or third-party contributors as
5+
* indicated by the @author tags or express copyright attribution
6+
* statements applied by the authors. All third-party contributions are
7+
* distributed under license by Red Hat Inc.
8+
*
9+
* This copyrighted material is made available to anyone wishing to use, modify,
10+
* copy, or redistribute it subject to the terms and conditions of the GNU
11+
* Lesser General Public License, as published by the Free Software Foundation.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16+
* for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public License
19+
* along with this distribution; if not, write to:
20+
* Free Software Foundation, Inc.
21+
* 51 Franklin Street, Fifth Floor
22+
* Boston, MA 02110-1301 USA
23+
*/
24+
package org.hibernate.test.propertyref.basic;
25+
26+
import static org.junit.Assert.assertEquals;
27+
import static org.junit.Assert.assertNotNull;
28+
29+
import org.hibernate.Session;
30+
import org.hibernate.Transaction;
31+
import org.hibernate.testing.TestForIssue;
32+
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
33+
import org.junit.Test;
34+
35+
/**
36+
* @author Brett Meyer
37+
*/
38+
public class BasicPropertiesTest extends BaseCoreFunctionalTestCase {
39+
@Override
40+
public String[] getMappings() {
41+
return new String[] { "propertyref/basic/EntityClass.hbm.xml" };
42+
}
43+
44+
/**
45+
* Really simple regression test for HHH-8689.
46+
*/
47+
@Test
48+
@TestForIssue(jiraKey = "HHH-8689")
49+
public void testProperties() {
50+
Session s = openSession();
51+
Transaction t = s.beginTransaction();
52+
EntityClass ec = new EntityClass();
53+
ec.setKey( 1l );
54+
ec.setField1( "foo1" );
55+
ec.setField2( "foo2" );
56+
s.persist( ec );
57+
t.commit();
58+
s.close();
59+
60+
s = openSession();
61+
t = s.beginTransaction();
62+
ec = (EntityClass) s.get( EntityClass.class, 1l );
63+
t.commit();
64+
s.close();
65+
66+
assertNotNull( ec );
67+
assertEquals( ec.getField1(), "foo1" );
68+
assertEquals( ec.getField2(), "foo2" );
69+
}
70+
}
71+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE hibernate-mapping PUBLIC
3+
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
4+
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" >
5+
6+
<hibernate-mapping>
7+
<class
8+
name="org.hibernate.test.propertyref.basic.EntityClass"
9+
table="table1" lazy="false">
10+
<id
11+
name="key"
12+
type="java.lang.Long"
13+
column="column1"/>
14+
15+
<properties name="refkey">
16+
<property name="field1" type="java.lang.String" column="column3" not-null="true" length="20" />
17+
<property name="field2" type="java.lang.String" column="column4" not-null="true" />
18+
</properties>
19+
20+
</class>
21+
</hibernate-mapping>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package org.hibernate.test.propertyref.basic;
2+
3+
public class EntityClass {
4+
5+
private Long key;
6+
7+
private String field1;
8+
9+
private String field2;
10+
11+
public Long getKey() {
12+
return this.key;
13+
}
14+
15+
public void setKey(Long key) {
16+
this.key = key;
17+
}
18+
19+
public String getField2() {
20+
return this.field2;
21+
}
22+
23+
public void setField2(String field2) {
24+
this.field2 = field2;
25+
}
26+
27+
public String getField1() {
28+
return this.field1;
29+
}
30+
31+
public void setField1(String field1) {
32+
this.field1 = field1;
33+
}
34+
35+
}

0 commit comments

Comments
 (0)