HHH-6271 Adding explicit test showing that orm version 1 works

This commit is contained in:
Hardy Ferentschik 2012-03-15 11:17:47 +01:00 committed by Strong Liu
parent 9272a905a0
commit ddcd060441
2 changed files with 64 additions and 0 deletions

View File

@ -0,0 +1,61 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.xml.ejb3;
import org.junit.Test;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
@TestForIssue(jiraKey = "HHH-6271")
public class OrmVersion1SupportedTest extends BaseCoreFunctionalTestCase {
@Test
public void testOrm1Support() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
Light light = new Light();
light.name = "the light at the end of the tunnel";
s.persist( light );
s.flush();
s.clear();
assertEquals( 1, s.getNamedQuery( "find.the.light" ).list().size() );
tx.rollback();
s.close();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] { Light.class };
}
@Override
protected String[] getXmlFiles() {
return new String[] { "org/hibernate/test/annotations/xml/ejb3/orm2.xml" };
}
}

View File

@ -7,6 +7,9 @@
>
<!-- use orm_1_0 on purpose (backward compatibility test -->
<package>org.hibernate.test.annotations.xml.ejb3</package>
<named-query name="find.the.light">
<query>select l from Light l</query>
</named-query>
<entity class="Light" access="FIELD" metadata-complete="true">
<attributes>
<id name="name">