Package org.tmatesoft.sqljet.core.table

Examples of org.tmatesoft.sqljet.core.table.ISqlJetTransaction


        });
    }
   
    @Test
    public void testRowCountIsStatelessWhenIndexIsNotUnique() throws SqlJetException {
        db.runReadTransaction(new ISqlJetTransaction() {
            public Object run(SqlJetDb db) throws SqlJetException {
                SqlJetScope scope = new SqlJetScope(new Object[] {1, 2}, true, new Object[] {1, 2}, true);
                ISqlJetCursor cursor = db.getTable("pairs").scope("pairs_idx", scope);
       
                Assert.assertTrue(!cursor.eof());
View Full Code Here


        List<?> actualValuesInScope = queryScope(scope, tableName, indexName, allFields);
        Assert.assertTrue(Arrays.deepEquals(expected.toArray(), actualValuesInScope.toArray()));
    }

    private List<?> queryScope(final SqlJetScope scope, final String tableName, final String indexName, final boolean allFields) throws SqlJetException {
        return (List<?>) db.runReadTransaction(new ISqlJetTransaction() {
            public Object run(SqlJetDb db) throws SqlJetException {
                List<Object> valuesInScope = new ArrayList<Object>()
                ISqlJetCursor scopeCursor = db.getTable(tableName).scope(indexName, scope);
                Assert.assertNotNull(scopeCursor);
                try {
View Full Code Here

    public void tearDown() throws Exception {
    }

    @Test
    public void testIsNull() throws Exception {
        db.runTransaction(new ISqlJetTransaction() {
            public Object run(SqlJetDb db) throws SqlJetException {
              ISqlJetTable table = db.getTable("beans");
              table.insertOr(SqlJetConflictAction.REPLACE, null, "SOME MESSAGE");
              return true;
            }
          }, SqlJetTransactionMode.WRITE);

         db.runTransaction(new ISqlJetTransaction() {
            public Object run(SqlJetDb db) throws SqlJetException {
              ISqlJetTable table = db.getTable("beans");
              ISqlJetCursor cur = table.lookup(table.getPrimaryKeyIndexName(),1);
              if (!cur.eof()) {
                long v = cur.getInteger(0);
View Full Code Here

    @Test
    public void malformedCreateTable() throws Exception {

        db.getOptions().setAutovacuum(true);
        db.runTransaction(new ISqlJetTransaction() {
            public Object run(SqlJetDb db) throws SqlJetException {
                db.getOptions().setUserVersion(1);
                return true;
            }
        }, SqlJetTransactionMode.WRITE);
View Full Code Here

    @Test
    public void malformedCreateTableIfNotExists() throws Exception {

        db.getOptions().setAutovacuum(true);
        db.runTransaction(new ISqlJetTransaction() {
            public Object run(SqlJetDb db) throws SqlJetException {
                db.getOptions().setUserVersion(1);
                return true;
            }
        }, SqlJetTransactionMode.WRITE);
View Full Code Here

    @Test
    public void malformedCreateTableExistsFail() throws Exception {

        db.getOptions().setAutovacuum(true);
        db.runTransaction(new ISqlJetTransaction() {
            public Object run(SqlJetDb db) throws SqlJetException {
                db.getOptions().setUserVersion(1);
                return true;
            }
        }, SqlJetTransactionMode.WRITE);
View Full Code Here

    @Test
    public void caseInsensitiveIndicesTest() throws SqlJetException {
        final ISqlJetTable t = db.getTable(db.createTable("create table t(a int)").getName());
        db.createIndex("create index i on t(a)");
        db.runReadTransaction(new ISqlJetTransaction() {
            public Object run(SqlJetDb db) throws SqlJetException {
                Assert.assertNotNull(t.getIndexDef("I"));
                Assert.assertNotNull(t.order("I"));
                Assert.assertNotNull(t.lookup("I", 0));
                Assert.assertNotNull(t.scope("I", new Object[] { 0 }, new Object[] { 0 }));
                return null;
            }
        });
        db.createIndex("create index II on t(a)");
        db.runReadTransaction(new ISqlJetTransaction() {
            public Object run(SqlJetDb db) throws SqlJetException {
                Assert.assertNotNull(t.getIndexDef("ii"));
                Assert.assertNotNull(t.order("ii"));
                Assert.assertNotNull(t.scope("ii", new Object[] { 0 }, new Object[] { 0 }));
                return null;
View Full Code Here

    @Test
    public void clearCellError() throws Exception {

        db.getOptions().setAutovacuum(true);
        db.runTransaction(new ISqlJetTransaction() {
            public Object run(SqlJetDb db) throws SqlJetException {
                db.getOptions().setUserVersion(1);
                return true;
            }
        }, SqlJetTransactionMode.WRITE);
View Full Code Here

            db.close();
    }

    @Test
    public void createTableTest() throws SqlJetException {
        db.runWriteTransaction(new ISqlJetTransaction() {

            public Object run(SqlJetDb db) throws SqlJetException {
                final ISqlJetTableDef createTable = db
                        .createTable("create table test( id integer primary key, name text )");
                final ISqlJetTable openTable = db.getTable(createTable.getName());
View Full Code Here

        });
    }

    @Test(expected = SqlJetException.class)
    public void createTableTest1() throws SqlJetException {
        db.runWriteTransaction(new ISqlJetTransaction() {

            public Object run(SqlJetDb db) throws SqlJetException {
                db.createTable("create table test1( id integer primary key, name text )");
                return null;
            }
View Full Code Here

TOP

Related Classes of org.tmatesoft.sqljet.core.table.ISqlJetTransaction

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.