Package com.jengine.orm.db

Examples of com.jengine.orm.db.DBConnection


        EhcacheManager cacheManager = new EhcacheManager(newEhcacheManager());
        Provider provider = new MySQLProvider(adapter, cacheManager);
        DB db = DBFactory.register(new DB(provider));

        // testing
        DBConnection connection = db.getConnection();
        try {
            test1();
            test2();
            test3();
            test4();
View Full Code Here


        for (int i=0; i < 10; i++) {
            threads.add(new Thread() {
                public void run() {
                    try {
                        DBConnection connection = DBFactory.get().getConnection();
                        try {
                            check(Book.cls.get(1).getLibrary().equals(Library.cls.get(1)));
                            Library globe = Library.cls.filter("name = ?", "Globe").one();
                            check( globe.getMemberList().size() == 4 );
                            check( globe.getMembers().list().size() == 4 );
View Full Code Here

     * Transaction testing
     */
    public static void test9() throws Exception {
        System.out.println("** Test 9: Transaction testing");

        DBConnection connection = DBFactory.get().getConnection();
        clearData();
        try {
            connection.startTransaction();
            loadData();
            throw new Exception("test!!!");
        } catch (Exception e) {
            connection.rollback();
            // checking
            check( Author.cls.count() == 0 );
            check( Library.cls.count() == 0 );
            check( Book.cls.count() == 0 );
            check( Member.cls.count() == 0 );
            check( Transaction.cls.count() == 0 );
        } finally {
            connection.finishTransaction();
        }

        clearData();
        connection.startTransaction();
        loadData();
        connection.commit();
        check( Author.cls.count() > 0 );
        check( Library.cls.count() > 0 );
        check( Book.cls.count() > 0 );
        check( Member.cls.count() > 0 );
        check( Transaction.cls.count() > 0 );
        connection.finishTransaction();


        clearData();
        connection.startTransaction();
        loadData();
            // save point
            DBSavePoint point = connection.savePoint();
            Author.cls.get(1).setLastName("test1");
            connection.rollback(point);
            connection.releasePoint(point);
        connection.commit();
        check( Author.cls.count() > 0 );
        check( Library.cls.count() > 0 );
        check( Book.cls.count() > 0 );
        check( Member.cls.count() > 0 );
        check( Transaction.cls.count() > 0 );
        connection.finishTransaction();
    }
View Full Code Here

TOP

Related Classes of com.jengine.orm.db.DBConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.