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());
}
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;
}
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());
}
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());
}
Aggregations