Search in sources :

Example 6 with Configuration

use of com.querydsl.sql.Configuration in project querydsl by querydsl.

the class SQLCodegenModule method configure.

@Override
protected void configure() {
    super.configure();
    bind(NamingStrategy.class, DefaultNamingStrategy.class);
    bind(Configuration.class, new Configuration(SQLTemplates.DEFAULT));
    bind(Serializer.class, MetaDataSerializer.class);
    bind(QueryTypeFactory.class, SQLQueryTypeFactory.class);
    bind(BEAN_SERIALIZER, (Class<?>) null);
    bind(INNER_CLASSES_FOR_KEYS, false);
    bind(BEAN_PREFIX, "");
    bind(BEAN_SUFFIX, "");
    bind(BEAN_PACKAGE_NAME, "com.example");
    bind(PACKAGE_NAME, "com.example");
    bind(BEAN_SERIALIZER, (Class<?>) null);
    bind(SCHEMA_TO_PACKAGE, false);
    bindInstance(ENTITYPATH_TYPE, RelationalPathBase.class);
    bind(COLUMN_COMPARATOR, null);
}
Also used : Configuration(com.querydsl.sql.Configuration)

Example 7 with Configuration

use of com.querydsl.sql.Configuration in project querydsl by querydsl.

the class NativeSQLSerializerTest method in.

@Test
public void in() {
    Configuration conf = new Configuration(new MySQLTemplates());
    NativeSQLSerializer serializer = new NativeSQLSerializer(conf, true);
    DefaultQueryMetadata md = new DefaultQueryMetadata();
    SAnimal cat = SAnimal.animal_;
    md.addJoin(JoinType.DEFAULT, cat);
    md.addWhere(cat.name.in("X", "Y"));
    md.setProjection(cat.id);
    serializer.serialize(md, false);
    assertEquals("select animal_.id\n" + "from animal_ animal_\n" + "where animal_.name in (?1, ?2)", serializer.toString());
}
Also used : MySQLTemplates(com.querydsl.sql.MySQLTemplates) SAnimal(com.querydsl.jpa.domain.sql.SAnimal) Configuration(com.querydsl.sql.Configuration) DefaultQueryMetadata(com.querydsl.core.DefaultQueryMetadata) Test(org.junit.Test)

Example 8 with Configuration

use of com.querydsl.sql.Configuration 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)

Aggregations

Configuration (com.querydsl.sql.Configuration)8 Test (org.junit.Test)4 MySQLTemplates (com.querydsl.sql.MySQLTemplates)3 Connection (java.sql.Connection)3 SQLException (java.sql.SQLException)3 SimpleType (com.mysema.codegen.model.SimpleType)2 BeanSerializer (com.querydsl.codegen.BeanSerializer)2 PathBuilder (com.querydsl.core.types.dsl.PathBuilder)2 MetaDataExporter (com.querydsl.sql.codegen.MetaDataExporter)2 NumericMapping (com.querydsl.sql.codegen.support.NumericMapping)2 RenameMapping (com.querydsl.sql.codegen.support.RenameMapping)2 TypeMapping (com.querydsl.sql.codegen.support.TypeMapping)2 File (java.io.File)2 DefaultQueryMetadata (com.querydsl.core.DefaultQueryMetadata)1 SAnimal (com.querydsl.jpa.domain.sql.SAnimal)1 AbstractJDBCTest (com.querydsl.sql.AbstractJDBCTest)1 DefaultNamingStrategy (com.querydsl.sql.codegen.DefaultNamingStrategy)1 NamingStrategy (com.querydsl.sql.codegen.NamingStrategy)1 IOException (java.io.IOException)1 PreparedStatement (java.sql.PreparedStatement)1