⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 arraytest.java

📁 hibernate3.2.6源码和jar包
💻 JAVA
字号:
//$Id: ArrayTest.java 11282 2007-03-14 22:05:59Z epbernard $package org.hibernate.test.annotations.array;import org.hibernate.Session;import org.hibernate.Transaction;import org.hibernate.test.annotations.TestCase;/** * @author Emmanuel Bernard */public class ArrayTest extends TestCase {	public void testOneToMany() throws Exception {		Session s;		Transaction tx;		s = openSession();		tx = s.beginTransaction();		Competitor c1 = new Competitor();		c1.setName( "Renault" );		Competitor c2 = new Competitor();		c2.setName( "Ferrari" );		Contest contest = new Contest();		contest.setResults( new Competitor[]{c1, c2} );		s.persist( contest );		tx.commit();		s.close();		s = openSession();		tx = s.beginTransaction();		contest = (Contest) s.get( Contest.class, contest.getId() );		assertNotNull( contest );		assertNotNull( contest.getResults() );		assertEquals( 2, contest.getResults().length );		assertEquals( c2.getName(), contest.getResults()[1].getName() );		tx.commit();		s.close();	}	public ArrayTest(String x) {		super( x );	}	protected Class[] getMappings() {		return new Class[]{				Competitor.class,				Contest.class		};	}}

⌨️ 快捷键说明

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