entitynonentitytest.java

来自「hibernate3.2.6源码和jar包」· Java 代码 · 共 44 行

JAVA
44
字号
//$Id: EntityNonEntityTest.java 11282 2007-03-14 22:05:59Z epbernard $package org.hibernate.test.annotations.entitynonentity;import org.hibernate.Session;import org.hibernate.Transaction;import org.hibernate.test.annotations.TestCase;/** * @author Emmanuel Bernard */public class EntityNonEntityTest extends TestCase {	public void testMix() throws Exception {		GSM gsm = new GSM();		gsm.brand = "Sony";		gsm.frequency = 900;		gsm.isNumeric = true;		gsm.number = 2;		gsm.species = "human";		Session s = openSession();		Transaction tx = s.beginTransaction();		s.persist( gsm );		tx.commit();		s.clear();		tx = s.beginTransaction();		gsm = (GSM) s.get( GSM.class, gsm.id );		assertEquals( "top mapped superclass", 2, gsm.number );		assertNull( "non entity between mapped superclass and entity", gsm.species );		assertTrue( "mapped superclass under entity", gsm.isNumeric );		assertNull( "non entity under entity", gsm.brand );		assertEquals( "leaf entity", 900, gsm.frequency );		s.delete( gsm );		tx.commit();		s.close();	}	protected Class[] getMappings() {		return new Class[]{				Phone.class,				Voice.class,				GSM.class		};	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?