01: package allinone;
02:
03: import com.lutris.appserver.server.sql.*;
04: import com.lutris.util.*;
05: import org.enhydra.dods.*;
06: import java.sql.SQLException;
07:
08: import javax.swing.*;
09: import java.util.*;
10: import java.awt.*;
11: import java.awt.event.*;
12: import java.net.*;
13: import java.io.*;
14: import org.apache.log4j.Logger;
15: import org.apache.log4j.xml.DOMConfigurator;
16: import com.lutris.appserver.server.sql.*;
17: import allinone.data.disc.*;
18: import allinone.data.person.*;
19:
20: public class MultiTransTest {
21:
22: public void runTest(DBTransaction dbTrans1) {
23: try {
24: System.err
25: .println("___ - + * startin MultiTransaction * + - ___");
26: PersonDO person1 = PersonDO.createVirgin(dbTrans1);
27:
28: person1.setFirstname("Person1Name");
29: person1.setLastname("Person1LastName");
30: person1.setLogin("p1");
31: person1.setPassword("p1");
32: person1.save(dbTrans1);
33: dbTrans1.write();
34: dbTrans1.commit();
35: System.err.println("-----person1------");
36: System.err.println(person1);
37: System.err.println("------------------");
38:
39: DiscDO disc1 = DiscDO.createVirgin(dbTrans1);
40: disc1.setArtist("Artist1");
41: disc1.setTitle("Disc test1");
42: disc1.setGenre("pop1");
43: disc1.setOwner(person1);
44: disc1.setIsLiked(false);
45: disc1.save(dbTrans1);
46: System.err.println("----disc1---------");
47: System.err.println(disc1);
48: System.err.println("------------------");
49:
50: String temp = disc1.getHandle();
51: dbTrans1.commit();
52: dbTrans1.release();
53:
54: DBTransaction dbTrans2 = DODS.getDatabaseManager()
55: .createTransaction();
56: DiscDO disc2 = DiscDO.createExisting(temp, dbTrans2);
57: System.err.println();
58: System.err.println(disc2);
59:
60: PersonDO pers2 = disc2.getOwner();
61: System.err.println("-----pers2--------");
62: System.err.println(pers2);
63: System.err.println("------------------");
64: dbTrans2.commit();
65: dbTrans2.release();
66: } catch (Exception ex) {
67: System.err.println(ex.toString());
68: ex.printStackTrace();
69: }
70: }
71: }
|