Package com.mysema.query.types.path

Examples of com.mysema.query.types.path.StringPath


        assertEquals(2l, query().from(employee).where(where).count());
    }

    @Test
    public void Precedence2() {
        StringPath fn = employee.firstname;
        StringPath ln = employee.lastname;
        Predicate where = fn.eq("Mike").and(ln.eq("Smith").or(fn.eq("Joe")).and(ln.eq("Divis")));
        assertEquals(0l, query().from(employee).where(where).count());
    }
View Full Code Here


    @Test
    public void DynamicQuery() {
        Path<Object> userPath = Expressions.path(Object.class, "user");
        NumberPath<Long> idPath = Expressions.numberPath(Long.class, userPath, "id");
        StringPath usernamePath = Expressions.stringPath(userPath, "username");
        Expression<?> sq = new SQLSubQuery()
            .from(userPath).where(idPath.eq(1l))
            .list(idPath, usernamePath);

        SQLSerializer serializer = new SQLSerializer(Configuration.DEFAULT);
View Full Code Here

    @Test
    public void DynamicQuery2() {
        PathBuilder<Object> userPath = new PathBuilder<Object>(Object.class, "user");
        NumberPath<Long> idPath = userPath.getNumber("id", Long.class);
        StringPath usernamePath = userPath.getString("username");
        Expression<?> sq = new SQLSubQuery()
            .from(userPath).where(idPath.eq(1l))
            .list(idPath, usernamePath);

        SQLSerializer serializer = new SQLSerializer(Configuration.DEFAULT);
View Full Code Here

    private QueryMetadata metadata = new DefaultQueryMetadata();

    @Test
    public void Serialization() throws IOException, ClassNotFoundException{
        StringPath expr = new StringPath("str");
        metadata.addJoin(JoinType.DEFAULT, expr);
        metadata.addFlag(new QueryFlag(Position.AFTER_FILTERS, ""));
        metadata.addGroupBy(expr);
        metadata.addHaving(expr.isEmpty());       
//        metadata.getJoins().get(0).addFlag(new JoinFlag(""));
        metadata.addJoinCondition(expr.isEmpty());
        metadata.addOrderBy(expr.asc());
        metadata.addProjection(expr);
        metadata.addWhere(expr.isEmpty());
       
        // serialize metadata
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream out = new ObjectOutputStream(baos);
        out.writeObject(metadata);
View Full Code Here

public class PrecedenceTest {
   
    @Test
    public void test() {
        StringPath str1 = new StringPath("str1");
        StringPath str2 = new StringPath("str2");
        BooleanExpression pending = str1.eq("3").and(str2.eq("1"));
        BooleanExpression notNew = str1.ne("1").and(str2.in("2", "3"));      
        BooleanExpression whereClause = str1.eq("a").and(pending.or(notNew));
        String str = new SQLSerializer(Configuration.DEFAULT).handle(whereClause).toString();
        assertEquals("str1 = ? and (str1 = ? and str2 = ? or str1 != ? and str2 in (?, ?))", str);
    }
View Full Code Here

        String var = "var"+ arg.getClass().getSimpleName() + "_" + arg.toString().replace(' ', '_');
        return new PathBuilder<D>((Class)arg.getClass(), var);
    }

    public static StringPath var(String arg) {
        return new StringPath(arg.replace(' ', '_'));
    }
View Full Code Here

   
    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Before
    public void setUp() {
        num = new NumberPath<Integer>(Integer.class, "num");
        str = new StringPath("str");
        date = new DatePath<Date>(Date.class, "date");
        QueryMixin query = new QueryMixin();
        query.from(num, str);
        sub = new DetachableMixin(query);
    }
View Full Code Here

    @Test
    @SuppressWarnings("unchecked")
    public void test() {
        DummyQuery query = new DummyQuery();
        DummyProjectable projectable = new DummyProjectable();
        SimpleProjectableAdapter simpleQuery = new SimpleProjectableAdapter(query, projectable, new StringPath("a"));
       
        simpleQuery.count();
        simpleQuery.distinct().count();
        assertNotNull(simpleQuery.list());
        assertNotNull(simpleQuery.distinct().list());
View Full Code Here

    public <T> Path<T> createSimplePath(Class<T> type, PathMetadata<?> metadata) {
        return new SimplePath<T>(type, metadata);
    }
    @Override
    public Path<String> createStringPath(PathMetadata<?> metadata) {
        return new StringPath(metadata);
    }
View Full Code Here

public class SerializerBaseTest {

    @Test
    public void test() {
        DummySerializer serializer = new DummySerializer(new JavaTemplates());
        StringPath strPath = new StringPath("str");
        // path
        serializer.handle(strPath);
        // operation
        serializer.handle(strPath.isNotNull());
        // long path
        serializer.handle(new PathBuilder<Object>(Object.class,"p").getList("l",Map.class).get(0));
        // constant
        serializer.handle(ConstantImpl.create(""));
        //  custom
View Full Code Here

TOP

Related Classes of com.mysema.query.types.path.StringPath

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.