Search in sources :

Example 1 with Param

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

the class DefaultQueryMetadataTest method setParam.

@SuppressWarnings("unchecked")
@Test
public void setParam() {
    metadata.setParam(new Param(String.class, "str"), ConstantImpl.create("X"));
    assertEquals(1, metadata.getParams().size());
    assertTrue(metadata.getParams().get(new Param(String.class, "str")).equals(ConstantImpl.create("X")));
}
Also used : Param(com.querydsl.core.types.dsl.Param) Test(org.junit.Test)

Example 2 with Param

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

the class LuceneQueryTest method uniqueResult_with_param.

@Test
public void uniqueResult_with_param() {
    final Param<String> param = new Param<String>(String.class, "title");
    query.set(param, "Nummi");
    query.where(title.startsWith(param));
    final Document document = query.fetchOne();
    assertEquals("Nummisuutarit", document.get("title"));
}
Also used : Param(com.querydsl.core.types.dsl.Param) Document(org.apache.lucene.document.Document) Test(org.junit.Test)

Example 3 with Param

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

the class DeleteBase method delete_with_subQuery_exists_Params.

@Test
public void delete_with_subQuery_exists_Params() {
    QSurvey survey1 = new QSurvey("s1");
    QEmployee employee = new QEmployee("e");
    Param<Integer> param = new Param<Integer>(Integer.class, "param");
    SQLQuery<?> sq = query().from(employee).where(employee.id.eq(param));
    sq.set(param, -12478923);
    SQLDeleteClause delete = delete(survey1);
    delete.where(survey1.name.eq("XXX"), sq.exists());
    assertEquals(0, delete.execute());
}
Also used : SQLDeleteClause(com.querydsl.sql.dml.SQLDeleteClause) Param(com.querydsl.core.types.dsl.Param) QSurvey(com.querydsl.sql.domain.QSurvey) QEmployee(com.querydsl.sql.domain.QEmployee) Test(org.junit.Test)

Example 4 with Param

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

the class UpdateBase method update_with_subQuery_exists_Params.

@Test
public void update_with_subQuery_exists_Params() {
    QSurvey survey1 = new QSurvey("s1");
    QEmployee employee = new QEmployee("e");
    Param<Integer> param = new Param<Integer>(Integer.class, "param");
    SQLQuery<?> sq = query().from(employee).where(employee.id.eq(param));
    sq.set(param, -12478923);
    SQLUpdateClause update = update(survey1);
    update.set(survey1.name, "AA");
    update.where(sq.exists());
    assertEquals(0, update.execute());
}
Also used : SQLUpdateClause(com.querydsl.sql.dml.SQLUpdateClause) Param(com.querydsl.core.types.dsl.Param) QSurvey(com.querydsl.sql.domain.QSurvey) QEmployee(com.querydsl.sql.domain.QEmployee) Test(org.junit.Test)

Example 5 with Param

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

the class LuceneQueryTest method uniqueResult_with_param.

@Test
public void uniqueResult_with_param() {
    final Param<String> param = new Param<String>(String.class, "title");
    query.set(param, "Nummi");
    query.where(title.startsWith(param));
    final Document document = query.fetchOne();
    assertEquals("Nummisuutarit", document.get("title"));
}
Also used : Param(com.querydsl.core.types.dsl.Param) Document(org.apache.lucene.document.Document) Test(org.junit.Test)

Aggregations

Param (com.querydsl.core.types.dsl.Param)5 Test (org.junit.Test)5 QEmployee (com.querydsl.sql.domain.QEmployee)2 QSurvey (com.querydsl.sql.domain.QSurvey)2 Document (org.apache.lucene.document.Document)2 SQLDeleteClause (com.querydsl.sql.dml.SQLDeleteClause)1 SQLUpdateClause (com.querydsl.sql.dml.SQLUpdateClause)1