Package com.mobixess.jodb.soda.api

Examples of com.mobixess.jodb.soda.api.Query


        sessionContainer.commit();
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
        Query query = sessionContainer.query();
       
        query.descend("_val1").constrain(objectWithEnum._val1);
        List list = query.execute();
       
        if(list.size()!=1){
            throw new RuntimeException(""+list.size());
        }
       
        Object_Enum objectWithEnumFromDb = (Object_Enum) list.get(0);
       
        if(!objectWithEnumFromDb._val1.equals(objectWithEnum._val1)){
            throw new RuntimeException();
        }
       
        Object_Enum objectWithEnum1 = new Object_Enum();
        objectWithEnum1._val1 = TEST_ENUM.ENUM_VAL2;
       
        sessionContainer.set(objectWithEnum1);
        sessionContainer.commit();
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
       
        query.descend("_val1").constrain(objectWithEnum._val1).not();
       
        list = query.execute();
       
        if(list.size()!=1){
            throw new RuntimeException();
        }
       
        objectWithEnumFromDb = (Object_Enum) list.get(0);
       
        if(!objectWithEnumFromDb._val1.equals(objectWithEnum1._val1)){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
       
        query.constrain(objectWithEnum._val1);
       
        list = query.execute();
       
        if(list.size()!=1){
            throw new RuntimeException();
        }
       
        Enum enumFromDb = (Enum) list.get(0);
       
        if(!enumFromDb.equals(objectWithEnum._val1)){
            throw new RuntimeException();
        }
       
        query = sessionContainer.query();
       
        query.constrain(objectWithEnum._val1).not();
       
        list = query.execute();
       
        if(list.size()!=1){
            throw new RuntimeException();
        }
       
        enumFromDb = (Enum) list.get(0);
       
        if(!enumFromDb.equals(objectWithEnum1._val1)){
            throw new RuntimeException();
        }
       
        query = sessionContainer.query();
       
        query.constrain(objectWithEnum._val1).greater();
       
        list = query.execute();
       
        if(list.size()!=1){
            throw new RuntimeException();
        }
       
        enumFromDb = (Enum) list.get(0);
       
        if(!enumFromDb.equals(objectWithEnum1._val1)){
            throw new RuntimeException();
        }
       
        query = sessionContainer.query();
       
        query.constrain(objectWithEnum._val1).greater().or(query.constrain(objectWithEnum._val1));
       
        list = query.execute();
       
        if(list.size()!=2){
            throw new RuntimeException(""+list.size());
        }
        sessionContainer.close();
View Full Code Here


                continue;
            }
            if(defaultIgnoreValues.contains(descendantValue)){
                continue;
            }
            Query descendantQuery = (QueryNode) descend(descendant.getName());
            descendantQuery.constrain(descendantValue);
        }
        return;
    }
View Full Code Here

        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        Query query = sessionContainer.query();
        pattern = new ObjectA((byte)4,(short)3,null);
        query.constrain(pattern);
        list = query.execute();
        if(list.size()!=1){
            throw new RuntimeException(""+list.size());
        }
        fromDb = (ObjectA) list.get(0);
        if(fromDb.getVal1()!=pattern.getVal1() || fromDb.getVal2()!=pattern.getVal2()|| fromDb.getVal3()!=pattern.getVal3()){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
       
        query = sessionContainer.query();
        pattern = new ObjectA((byte)2,(short)0,null);
        query.constrain(pattern);
        list = query.execute();
        if(list.size()!=1){
            throw new RuntimeException(""+list.size());
        }
        fromDb = (ObjectA) list.get(0);
        if(fromDb.getVal1()!=objectA.getVal1() || fromDb.getVal2()!=objectA.getVal2()|| fromDb.getVal3()!=objectA.getVal3()){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
        pattern = new ObjectA((byte)0,(short)3,null);
        query.constrain(pattern);
        list = query.execute();
        if(list.size()!=2){
            throw new RuntimeException(""+list.size());
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        ObjectWithString objectWithString = new ObjectWithString();
        objectWithString._val1 = "test";
        ObjectWithString objectWithString1 = new ObjectWithString();
        objectWithString1._val1 = "test1";
        sessionContainer.set(objectWithString);
        sessionContainer.set(objectWithString1);
        sessionContainer.commit();
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        ObjectWithString objectWithStringPattern = new ObjectWithString();
        objectWithStringPattern._val1 = "test";
        query = sessionContainer.query();
        query.constrain(objectWithStringPattern);
        list = query.execute();
        if(list.size()!=1){
            throw new RuntimeException(""+list.size());
        }
       
        ObjectWithString objectWithStringfromDb = (ObjectWithString) list.get(0);
        if(!objectWithStringfromDb._val1.equals(objectWithStringPattern._val1 )){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }

        query = sessionContainer.query();
        Constraint constraint = query.constrain(objectWithStringPattern);
        ObjectWithString objectWithStringPattern1 = new ObjectWithString();
        objectWithStringPattern1._val1 = "test1";
        query.constrain(objectWithStringPattern1).or(constraint);
       
        list = query.execute();
        if(list.size()!=2){
            throw new RuntimeException(""+list.size());
        }
       
        sessionContainer.close();
View Full Code Here

        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }

        Query query = sessionContainer.query();
        query.constrain(ObjectA.class);
        list = query.execute();
        if(list.size()!=1){
            throw new RuntimeException();
        }
        if(list.get(0).getClass() != ObjectA.class){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
        query = sessionContainer.query();
        query.constrain(ObjectA.class).not();
        list = query.execute();
        if(list.size()!=1){
            throw new RuntimeException();
        }
        if(list.get(0).getClass() != ObjectB.class){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
        query.constrain(ObjectA.class).or(query.constrain(ObjectB.class));
        list = query.execute();
        if(list.size()!=2){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
        query.constrain(ObjectA.class).or(query.constrain(ObjectB.class).not());
        list = query.execute();
        if(list.size()!=1){
            throw new RuntimeException();
        }
        if(list.get(0).getClass() != ObjectA.class){
            throw new RuntimeException();
        }
       
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
        query.descend("_val3").constrain(ObjectA.class);
        list = query.execute();
        if(list.size()!=1){
            throw new RuntimeException();
        }
        if(list.get(0).getClass() != ObjectB.class){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
        query.descend("_val3").constrain(ObjectB.class);
        list = query.execute();
        if(list.size()!=1){
            throw new RuntimeException();
        }
        if(list.get(0).getClass() != ObjectA.class){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
        query.descend("_val3").constrain(ObjectA.class);
        query.descend("_val2").constrain(short.class);
        list = query.execute();
        if(list.size()!=1){
            throw new RuntimeException();
        }
        if(list.get(0).getClass() != ObjectB.class){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
        Constraint constraint = query.descend("_val3").constrain(ObjectB.class);
        query.descend("_val2").constrain(short.class).or(constraint);
        list = query.execute();
        if(list.size()!=2){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
        constraint = query.descend("_val3").constrain(ObjectB.class);
        query.descend("_val2").constrain(short.class);
        list = query.execute();
        if(list.size()!=1){
            throw new RuntimeException();
        }
        if(list.get(0).getClass() != ObjectA.class){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
        constraint = query.descend("_val3").constrain(ObjectB.class);
        query.descend("_val2").constrain(int.class).or(constraint);
        list = query.execute();
        if(list.size()!=1){
            throw new RuntimeException();
        }
        if(list.get(0).getClass() != ObjectA.class){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
        constraint = query.descend("_val3").constrain(ObjectB.class);
        query.descend("_val2").constrain(int.class).and(constraint);
        list = query.execute();
        if(list.size()!=0){
            throw new RuntimeException();
        }
        sessionContainer.close();
    }
View Full Code Here

        sessionContainer.set(objectA);
        sessionContainer.set(objectB);

        sessionContainer.close();
        sessionContainer = getContainerForFile(testFile);
        Query query = sessionContainer.query();
        query.descend("_val1").constrain(new Byte((byte)2));
        List list = query.execute();
        if(list.size()!=1){
            throw new RuntimeException();
        }
        if(list.get(0).getClass() != ObjectA.class){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
        query.descend("_val1").constrain(new Byte((byte)2)).not();
        list = query.execute();
        if(list.size()!=1){
            throw new RuntimeException();
        }
        if(list.get(0).getClass() != ObjectB.class){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
        query.descend("_val1").constrain(new Integer((byte)2)).not();
        list = query.execute();
        if(list.size()!=1){
            throw new RuntimeException();
        }
        if(list.get(0).getClass() != ObjectB.class){
            throw new RuntimeException();
        }
       
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
        query.descend("_val2").constrain(new Byte((byte)3));
        list = query.execute();
        if(list.size()!=1){
            throw new RuntimeException();
        }
        if(list.get(0).getClass() != ObjectA.class){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
        Constraint constraint = query.descend("_val2").constrain(new Byte((byte)3));
        query.descend("_val2").constrain(new Byte((byte)0)).or(constraint);
        list = query.execute();
        if(list.size()!=2){
            throw new RuntimeException();
        }
       
        query = sessionContainer.query();
        constraint = query.descend("_val2").constrain(3);
        query.descend("_val1").constrain((short)2).and(constraint);
        list = query.execute();
        if(list.size()!=1){
            throw new RuntimeException();
        }
        if(list.get(0).getClass() != ObjectA.class){
            throw new RuntimeException();
View Full Code Here

        sessionContainer.set(objectA);
        sessionContainer.set(objectB);

        sessionContainer.close();
        sessionContainer = getContainerForFile(testFile);
        Query query = sessionContainer.query();
       
        query.descend("_val1").constrain((byte)2).greater().equal();
        List list = query.execute();
        if(list.size()!=1){
            throw new RuntimeException();
        }
        if(list.get(0).getClass() != ObjectA.class){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
        query.descend("_val1").constrain((byte)2).greater();
        list = query.execute();
        if(list.size()!=0){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
        query.descend("_val1").constrain((byte)2).smaller();
        list = query.execute();
        if(list.size()!=1){
            throw new RuntimeException();
        }
       
        if(list.get(0).getClass() != ObjectB.class){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
        Constraint constraint = query.descend("_val1").constrain((byte)2).smaller();
        query.descend("_val2").constrain(2).greater().or(constraint);
        list = query.execute();
        if(list.size()!=2){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
        constraint = query.descend("_val1").constrain((byte)2).smaller();
        query.descend("_val2").constrain(2).greater().and(constraint);
        list = query.execute();
        if(list.size()!=0){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
       
        query = sessionContainer.query();
        constraint = query.constrain(ObjectA.class);
        query.descend("_val2").constrain(2).greater().and(constraint);
        list = query.execute();
        if(list.size()!=1){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
        constraint = query.constrain(ObjectA.class);
        query.descend("_val2").constrain(2).greater().or(constraint);
        list = query.execute();
        if(list.size()!=1){
            throw new RuntimeException();
        }
       
        if(reopen){
View Full Code Here

       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
        Query query = sessionContainer.query();
        query.constrain(new ObjectAEvaluation());
       
        List list = query.execute();
       
        if(list.size()!=1){
            throw new RuntimeException(""+list.size());
        }
       
        if(list.get(0) instanceof ObjectA){
        }else{
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
        query.constrain(new ObjectAEvaluation()).not();
       
        list = query.execute();
       
        if(list.size()!=1){
            throw new RuntimeException();
        }
       
        if(list.get(0) instanceof ObjectB){
        }else{
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
       
        query = sessionContainer.query();
        query.descend("_val2").constrain(new ObjectFieldEvaluation((short) 1));
       
        list = query.execute();
       
        if(list.size()!=1){
            throw new RuntimeException();
        }
       
        if(list.get(0) instanceof ObjectA){
        }else{
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
        query.descend("_val2").constrain(new ObjectFieldEvaluation((short) 0));
       
        list = query.execute();
       
        if(list.size()!=1){
            throw new RuntimeException();
        }
       
        if(list.get(0) instanceof ObjectB){
        }else{
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
        query.descend("_val2").constrain(new ObjectFieldEvaluation((short) 0)).not();
       
        list = query.execute();
       
        if(list.size()!=1){
            throw new RuntimeException();
        }
       
View Full Code Here

       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
        Query query = sessionContainer.query();
        if(ascending){
            query.descend("_val0").orderAscending();
        }else{
            query.descend("_val0").orderDescending();
        }
        if(ascending){
            query.descend("_val1").orderAscending();
        }else{
            query.descend("_val1").orderDescending();
        }
        JODBConfig.setCacheOnSortOperations(false);
        List list = query.execute();
       
        ObjectWithString prev = null;
       
        if(list.size() == 0){
            throw new RuntimeException();
        }
       
        for (int i = 0; i < list.size(); i++) {
            ObjectWithString current = (ObjectWithString) list.get(i);
            if(prev!=null){
                if(ascending){
                    if( prev._val1.charAt(0> current._val1.charAt(0)  ){
                        throw new RuntimeException();
                    }
                }else if(prev._val1.charAt(0< current._val1.charAt(0) ){
                    throw new RuntimeException();
                }
            }
            prev = current;
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
            query = sessionContainer.query();
            if(ascending){
                query.descend("_val1").orderAscending();
            }else{
                query.descend("_val1").orderDescending();
            }
        }
       
        JODBConfig.setCacheOnSortOperations(true);
        list = query.execute();
        if(list.size() == 0){
            throw new RuntimeException();
        }
       
        prev = null;
View Full Code Here

       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
        Query query = sessionContainer.query();
        if(ascending){
            query.descend("_val1").orderAscending();
        }else{
            query.descend("_val1").orderDescending();
        }
        if(ascending){
            query.descend("_val2").orderAscending();
        }else{
            query.descend("_val2").orderDescending();
        }
        JODBConfig.setCacheOnSortOperations(false);
        List list = query.execute();
        if(list.size() == 0){
            throw new RuntimeException();
        }
       
        ObjectA prev = null;
        for (int i = 0; i < list.size(); i++) {
            ObjectA current = (ObjectA) list.get(i);
            if(prev!=null){
                if(ascending){
                    if( prev.getVal2() > current.getVal2() ){
                        throw new RuntimeException();
                    }
                }else if(prev.getVal2() < current.getVal2() ){
                    throw new RuntimeException();
                }
            }
            prev = current;
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
            query = sessionContainer.query();
            if(ascending){
                query.descend("_val2").orderAscending();
            }else{
                query.descend("_val2").orderDescending();
            }
        }
       
        JODBConfig.setCacheOnSortOperations(true);
        list = query.execute();
        if(list.size() == 0){
            throw new RuntimeException();
        }
       
        prev = null;
View Full Code Here

        objectWithString._val1 = "test1";
        sessionContainer.set(objectWithString);
   
        sessionContainer.close();
        sessionContainer = getContainerForFile(testFile);
        Query query = sessionContainer.query();
       
        query.descend("_val1").constrain(objectWithString._val1);
        List list = query.execute();
       
        if(list.size()!=1){
            throw new RuntimeException();
        }
       
        ObjectWithString objectWithStringFromDb = (ObjectWithString) list.get(0);
       
        if(!objectWithStringFromDb._val1.equals(objectWithString._val1)){
            throw new RuntimeException();
        }
       
        ObjectWithString objectWithString1 = new ObjectWithString();
        objectWithString1._val1 = "test2";
       
        sessionContainer.set(objectWithString1);
        sessionContainer.commit();
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
       
        query.descend("_val1").constrain(objectWithString._val1).not();
       
        list = query.execute();
       
        if(list.size()!=1){
            throw new RuntimeException();
        }
       
        objectWithStringFromDb = (ObjectWithString) list.get(0);
       
        if(!objectWithStringFromDb._val1.equals(objectWithString1._val1)){
            throw new RuntimeException();
        }
       
        if(reopen){
            sessionContainer.close();
            sessionContainer = getContainerForFile(testFile);
        }
       
        query = sessionContainer.query();
       
        query.constrain(objectWithString._val1);
       
        list = query.execute();
       
        if(list.size()!=1){
            throw new RuntimeException();
        }
       
        String stringFromDb = (String) list.get(0);
       
        if(!stringFromDb.equals(objectWithString._val1)){
            throw new RuntimeException();
        }
       
        query = sessionContainer.query();
       
        query.constrain(objectWithString._val1).not();
       
        list = query.execute();
       
        if(list.size()!=1){
            throw new RuntimeException();
        }
       
        stringFromDb = (String) list.get(0);
       
        if(!stringFromDb.equals(objectWithString1._val1)){
            throw new RuntimeException();
        }
       
        query = sessionContainer.query();
       
        query.constrain(objectWithString._val1).greater();
       
        list = query.execute();
       
        if(list.size()!=1){
            throw new RuntimeException();
        }
       
        stringFromDb = (String) list.get(0);
       
        if(!stringFromDb.equals(objectWithString1._val1)){
            throw new RuntimeException();
        }
       
        query = sessionContainer.query();
       
        query.constrain(objectWithString._val1).greater().or(query.constrain(objectWithString._val1));
       
        list = query.execute();
       
        if(list.size()!=2){
            throw new RuntimeException(""+list.size());
        }
        sessionContainer.close();
View Full Code Here

TOP

Related Classes of com.mobixess.jodb.soda.api.Query

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.