📄 idtest.java
字号:
//$Id: IdTest.java,v 1.4 2005/02/25 12:44:44 maxcsaucdk Exp $package org.hibernate.test.metadata.id;import org.hibernate.Session;import org.hibernate.Transaction;import org.hibernate.test.metadata.TestCase;/** * @author Emmanuel Bernard */public class IdTest extends TestCase { public IdTest(String x) { super(x); } public void testTableGenerator() throws Exception { Session s = openSession(); Transaction tx = s.beginTransaction(); Ball b = new Ball(); Dog d = new Dog(); Computer c = new Computer(); s.persist(b); s.persist(d); s.persist(c); tx.commit(); s.close(); assertEquals( "table id not generated", new Long(1), b.getId() ); assertEquals( "generator should not be shared", new Integer(1), d.getId() ); assertEquals( "default value should work", new Long(1), c.getId() ); } public void testSequenceGenerator() throws Exception { Session s = openSession(); Transaction tx = s.beginTransaction(); Shoe b = new Shoe(); s.persist(b); tx.commit(); s.close(); assertNotNull( b.getId() ); } public void testClassLevelGenerator() throws Exception { Session s = openSession(); Transaction tx = s.beginTransaction(); Store b = new Store(); s.persist(b); tx.commit(); s.close(); assertNotNull( b.getId() ); } public void testMethodLevelGenerator() throws Exception { Session s = openSession(); Transaction tx = s.beginTransaction(); Department b = new Department(); s.persist(b); tx.commit(); s.close(); assertNotNull( b.getId() ); } /** * @see org.hibernate.test.metadata.TestCase#getMappings() */ protected Class[] getMappings() { return new Class[] { Ball.class, Shoe.class, Store.class, Department.class, Dog.class, Computer.class }; } /** * @see org.hibernate.test.metadata.TestCase#getAnnotatedPackages() */ protected String[] getAnnotatedPackages() { return new String[] { "org.hibernate.test.metadata" }; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -