Package org.caffinitas.mapper.core

Examples of org.caffinitas.mapper.core.Batch


    @Test(dependsOnMethods = "createSchema")
    public void batch_simple() throws Exception {
        PersistenceSession session = persistenceManager.createSession();
        try {
            Batch batch = session.startBatch();
            try {

                BatchEntity inst = new BatchEntity();
                inst.setId(1);
                inst.setVal("1");
                batch.insert(inst);

                inst = new BatchEntity();
                inst.setId(2);
                inst.setVal("2");
                batch.insert(inst);

                inst = new BatchEntity();
                inst.setId(3);
                inst.setVal("3");
                batch.insert(inst);
            } finally { batch.close(); } // Batch.close() implicitly calls Batch.submitBatch()

            BatchEntity loaded = session.loadOne(BatchEntity.class, 1);
            Assert.assertNotNull(loaded);
            Assert.assertEquals(loaded.getVal(), "1");
            loaded = session.loadOne(BatchEntity.class, 2);
View Full Code Here


    @Test(dependsOnMethods = "createSchema")
    public void batch_cas() throws Exception {

        PersistenceSession session = persistenceManager.createSession();
        try {
            Batch batch = session.startBatch();
            try {

                BatchCKEntity inst = new BatchCKEntity();
                inst.setPk(1);
                inst.setCk(1);
                inst.setVal("1");
                batch.insert(inst, PersistOption.ifNotExists());

                inst = new BatchCKEntity();
                inst.setPk(1);
                inst.setCk(2);
                inst.setVal("2");
                batch.insert(inst);

                inst = new BatchCKEntity();
                inst.setPk(1);
                inst.setCk(3);
                inst.setVal("3");
                batch.insert(inst, PersistOption.ifNotExists());
            } finally { batch.close(); // Batch.close() implicitly calls Batch.submitBatch()

            BatchCKEntity loaded = session.loadOne(BatchCKEntity.class, 1, 1);
            Assert.assertNotNull(loaded);
            Assert.assertEquals(loaded.getVal(), "1");
            loaded = session.loadOne(BatchCKEntity.class, 1, 2);
View Full Code Here

            inst.setPk(11);
            inst.setCk(2);
            inst.setVal("2");
            session.insert(inst, PersistOption.ifNotExists());

            Batch batch = session.startBatch();
            try {

                inst = new BatchCKEntity();
                inst.setPk(11);
                inst.setCk(2); // DUPLICATE !!
                inst.setVal("3");
                batch.insert(inst, PersistOption.ifNotExists());

                inst = new BatchCKEntity();
                inst.setPk(11);
                inst.setCk(2); // DUPLICATE !!
                inst.setVal("4");
                batch.insert(inst, PersistOption.ifNotExists());
            } finally { batch.close(); // Batch.close() implicitly calls Batch.submitBatch()

            BatchCKEntity loaded = session.loadOne(BatchCKEntity.class, 11, 1);
            Assert.assertNotNull(loaded);
            Assert.assertEquals(loaded.getVal(), "1");
            loaded = session.loadOne(BatchCKEntity.class, 11, 2);
View Full Code Here

    @Test(dependsOnMethods = "createSchema", expectedExceptions = InvalidQueryException.class)
    public void batch_cas_fail_pkMix() throws Exception {
        PersistenceSession session = persistenceManager.createSession();
        try {
            Batch batch = session.startBatch();
            try {

                BatchCKEntity inst = new BatchCKEntity();
                inst.setPk(21);
                inst.setCk(1);
                inst.setVal("1");
                batch.insert(inst, PersistOption.ifNotExists());

                inst = new BatchCKEntity();
                inst.setPk(22);
                inst.setCk(2);
                inst.setVal("2");
                batch.insert(inst, PersistOption.ifNotExists());
            } finally { batch.close(); // Batch.close() implicitly calls Batch.submitBatch()
        } finally {session.close();}
    }
View Full Code Here

TOP

Related Classes of org.caffinitas.mapper.core.Batch

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.