notfoundtest.java

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

JAVA
46
字号
//$Id: NotFoundTest.java 11282 2007-03-14 22:05:59Z epbernard $package org.hibernate.test.annotations.notfound;import org.hibernate.Session;import org.hibernate.Transaction;import org.hibernate.test.annotations.TestCase;/** * @author Emmanuel Bernard */public class NotFoundTest extends TestCase {	public void testManyToOne() throws Exception {		Currency euro = new Currency();		euro.setName( "Euro" );		Coin fiveC = new Coin();		fiveC.setName( "Five cents" );		fiveC.setCurrency( euro );		Session s = openSession();		s.getTransaction().begin();		s.persist( euro );		s.persist( fiveC );		s.getTransaction().commit();		s.clear();		Transaction tx = s.beginTransaction();		euro = (Currency) s.get( Currency.class, euro.getId() );		s.delete( euro );		tx.commit();		s.clear();		tx = s.beginTransaction();		fiveC = (Coin) s.get( Coin.class, fiveC.getId() );		assertNull( fiveC.getCurrency() );		s.delete( fiveC );		tx.commit();		s.close();	}	protected Class[] getMappings() {		return new Class[]{				Coin.class,				Currency.class		};	}}

⌨️ 快捷键说明

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