📄 abctest.java
字号:
//$Id: ABCTest.java,v 1.1.2.3 2003/11/08 09:46:22 oneovthafew Exp $package org.hibernate.test;import junit.framework.Test;import junit.framework.TestSuite;import junit.textui.TestRunner;import net.sf.hibernate.Session;import net.sf.hibernate.Transaction;public class ABCTest extends TestCase { public ABCTest(String arg0) { super(arg0); } public void testSubclassing() throws Exception { Session s = openSession(); Transaction t = s.beginTransaction(); C1 c1 = new C1(); D d = new D(); d.setAmount(213.34f); c1.setAddress("foo bar"); c1.setCount(23432); c1.setName("c1"); c1.setD(d); s.save(c1); d.setId( c1.getId() ); s.save(d); assertTrue( s.find("from c in class C2 where 1=1 or 1=1").size()==0 ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); c1 = (C1) s.load( A.class, c1.getId() ); assertTrue( c1.getAddress().equals("foo bar") && (c1.getCount()==23432) && c1.getName().equals("c1") && c1.getD().getAmount()>213.3f ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); c1 = (C1) s.load( B.class, c1.getId() ); assertTrue( c1.getAddress().equals("foo bar") && (c1.getCount()==23432) && c1.getName().equals("c1") && c1.getD().getAmount()>213.3f ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); c1 = (C1) s.load( C1.class, c1.getId() ); assertTrue( c1.getAddress().equals("foo bar") && (c1.getCount()==23432) && c1.getName().equals("c1") && c1.getD().getAmount()>213.3f ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); s.find("from b in class B"); t.commit(); s.close(); } public String[] getMappings() { return new String[] { "ABC.hbm.xml", "ABCExtends.hbm.xml" }; } public static Test suite() { return new TestSuite(ABCTest.class); } public static void main(String[] args) throws Exception { TestRunner.run( suite() ); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -