Search in sources :

Example 1 with PathBuilder

use of com.querydsl.core.types.dsl.PathBuilder in project querydsl by querydsl.

the class NativeSQLSerializerTest method path_column2.

@Test
public void path_column2() {
    PathBuilder<Entity> entity = new PathBuilder<Entity>(Entity.class, "entity");
    Configuration conf = new Configuration(new MySQLTemplates());
    NativeSQLSerializer serializer = new NativeSQLSerializer(conf, true);
    serializer.handle(entity.get("firstName"));
    assertEquals("entity.first_name", serializer.toString());
}
Also used : MySQLTemplates(com.querydsl.sql.MySQLTemplates) PathBuilder(com.querydsl.core.types.dsl.PathBuilder) Configuration(com.querydsl.sql.Configuration) Test(org.junit.Test)

Example 2 with PathBuilder

use of com.querydsl.core.types.dsl.PathBuilder in project querydsl by querydsl.

the class OrderHelper method join.

@SuppressWarnings("unchecked")
public static PathBuilder<?> join(JPQLQuery<?> query, PathBuilder<?> builder, Map<String, PathBuilder<?>> joins, String path) {
    PathBuilder<?> rv = joins.get(path);
    if (rv == null) {
        if (path.contains(".")) {
            String[] tokens = DOT.split(path);
            String[] parent = new String[tokens.length - 1];
            System.arraycopy(tokens, 0, parent, 0, tokens.length - 1);
            String parentKey = StringUtils.join(parent, ".");
            builder = join(query, builder, joins, parentKey);
            rv = new PathBuilder(Object.class, StringUtils.join(tokens, "_"));
            query.leftJoin((EntityPath) builder.get(tokens[tokens.length - 1]), rv);
        } else {
            rv = new PathBuilder(Object.class, path);
            query.leftJoin((EntityPath) builder.get(path), rv);
        }
        joins.put(path, rv);
    }
    return rv;
}
Also used : PathBuilder(com.querydsl.core.types.dsl.PathBuilder)

Example 3 with PathBuilder

use of com.querydsl.core.types.dsl.PathBuilder in project querydsl by querydsl.

the class NativeSQLSerializerTest method path_column.

@Test
public void path_column() {
    PathBuilder<Entity> entity = new PathBuilder<Entity>(Entity.class, "entity");
    Configuration conf = new Configuration(new MySQLTemplates());
    NativeSQLSerializer serializer = new NativeSQLSerializer(conf, true);
    serializer.handle(entity.get("name"));
    assertEquals("entity.name", serializer.toString());
}
Also used : MySQLTemplates(com.querydsl.sql.MySQLTemplates) PathBuilder(com.querydsl.core.types.dsl.PathBuilder) Configuration(com.querydsl.sql.Configuration) Test(org.junit.Test)

Example 4 with PathBuilder

use of com.querydsl.core.types.dsl.PathBuilder in project querydsl by querydsl.

the class SerializationTest method with_tuple.

@Test
public void with_tuple() {
    PathBuilder<Survey> survey = new PathBuilder<Survey>(Survey.class, "SURVEY");
    QSurvey survey2 = new QSurvey("survey2");
    SQLQuery<?> q = new SQLQuery<Void>();
    q.with(survey, survey.get(survey2.id), survey.get(survey2.name)).as(select(survey2.id, survey2.name).from(survey2));
    assertEquals("with SURVEY (ID, NAME) as (select survey2.ID, survey2.NAME\n" + "from SURVEY survey2)\n\n" + "from dual", q.toString());
}
Also used : PathBuilder(com.querydsl.core.types.dsl.PathBuilder) QSurvey(com.querydsl.sql.domain.QSurvey) QSurvey(com.querydsl.sql.domain.QSurvey) Test(org.junit.Test)

Aggregations

PathBuilder (com.querydsl.core.types.dsl.PathBuilder)4 Test (org.junit.Test)3 Configuration (com.querydsl.sql.Configuration)2 MySQLTemplates (com.querydsl.sql.MySQLTemplates)2 QSurvey (com.querydsl.sql.domain.QSurvey)1