KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > test > idclass > IdClassTest


1 //$Id: IdClassTest.java,v 1.1 2005/06/20 09:44:54 oneovthafew Exp $
2
package org.hibernate.test.idclass;
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 Gavin King
13  */

14 public class IdClassTest extends TestCase {
15     
16     public IdClassTest(String JavaDoc str) {
17         super(str);
18     }
19
20     public void testIdClass() {
21         Session s = openSession();
22         Transaction t = s.beginTransaction();
23         Customer cust = new Customer("JBoss", "RouteOne", "Detroit");
24         s.persist(cust);
25         t.commit();
26         s.close();
27         
28         s = openSession();
29         CustomerId custId = new CustomerId("JBoss", "RouteOne");
30         t = s.beginTransaction();
31         cust = (Customer) s.get(Customer.class, custId);
32         t.commit();
33         s.close();
34     }
35     
36     protected String JavaDoc[] getMappings() {
37         return new String JavaDoc[] { "idclass/Customer.hbm.xml" };
38     }
39
40     public static Test suite() {
41         return new TestSuite(IdClassTest.class);
42     }
43
44 }
45
46
Popular Tags