1
//$Id: IJTest.java 10976 2006-12-12 23:22:26Z steve.ebersole@jboss.com $
2
package org.hibernate.test.legacy;
4
import java.io.Serializable;
6
import junit.framework.Test;
8
import org.hibernate.LockMode;
9
import org.hibernate.classic.Session;
10
import org.hibernate.dialect.HSQLDialect;
11
import org.hibernate.dialect.OracleDialect;
12
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
17
public class IJTest extends LegacyTestCase {
19
public IJTest(String x) {
23
public String[] getMappings() {
24
return new String[] { "legacy/IJ.hbm.xml" };
27
public static Test suite() {
28
return new FunctionalTestClassTestSuite( IJTest.class );
31
public void testFormulaDiscriminator() throws Exception {
32
if ( ( getDialect() instanceof OracleDialect ) || ( getDialect() instanceof HSQLDialect ) ) return;
33
Session s = getSessions().openSession();
41
Serializable iid = s.save(i);
42
Serializable jid = s.save(j);
44
s.connection().commit();
47
getSessions().evict(I.class);
49
s = getSessions().openSession();
50
j = (J) s.get(I.class, jid);
51
i = (I) s.get(I.class, iid);
52
assertTrue( i.getClass()==I.class );
54
s.lock(i, LockMode.UPGRADE);
56
s.connection().commit();
59
s = getSessions().openSession();
60
j = (J) s.get(I.class, jid, LockMode.UPGRADE);
61
i = (I) s.get(I.class, iid, LockMode.UPGRADE);
63
s.connection().commit();
66
s = getSessions().openSession();
67
assertTrue( s.find("from I").size()==2 );
68
assertTrue( s.find("from J").size()==1 );
69
assertTrue( s.find("from I i where i.class = 0").size()==1 );
70
assertTrue( s.find("from I i where i.class = 1").size()==1 );
71
s.connection().commit();
74
s = getSessions().openSession();
75
j = (J) s.get(J.class, jid);
76
i = (I) s.get(I.class, iid);
80
s.connection().commit();