KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > test > array > ArrayTest


1 //$Id: ArrayTest.java,v 1.1 2005/04/26 16:58:52 oneovthafew Exp $
2
package org.hibernate.test.array;
3
4 import junit.framework.Test;
5 import junit.framework.TestSuite;
6
7 import org.hibernate.Session;
8 import org.hibernate.Transaction;
9 import org.hibernate.test.TestCase;
10
11 /**
12  * @author Emmanuel Bernard
13  */

14 public class ArrayTest extends TestCase {
15     
16     public void testArrayJoinFetch() throws Exception JavaDoc {
17         Session s;
18         Transaction tx;
19         s = openSession();
20         tx = s.beginTransaction();
21         A a = new A();
22         B b = new B();
23         a.setBs( new B[] {b} );
24         s.persist( a );
25         tx.commit();
26         s.close();
27
28         s = openSession();
29         tx = s.beginTransaction();
30         a = (A) s.get( A.class, a.getId() );
31         assertNotNull( a );
32         assertNotNull( a.getBs() );
33         assertEquals( a.getBs().length, 1 );
34         assertNotNull( a.getBs()[0] );
35         tx.commit();
36         s.close();
37     }
38     
39     public ArrayTest(String JavaDoc x) {
40         super( x );
41     }
42
43     public static Test suite() {
44         return new TestSuite( ArrayTest.class );
45     }
46
47     protected String JavaDoc[] getMappings() {
48         return new String JavaDoc[] {
49             "array/A.hbm.xml"
50         };
51     }
52 }
53
Popular Tags