Search in sources :

Example 6 with SQLInsertClause

use of com.querydsl.sql.dml.SQLInsertClause in project querydsl by querydsl.

the class MySQLQueryFactory method insertOnDuplicateKeyUpdate.

/**
 * Create a INSERT ... ON DUPLICATE KEY UPDATE clause
 *
 * @param entity table to insert to
 * @param clause clause
 * @return insert clause
 */
public SQLInsertClause insertOnDuplicateKeyUpdate(RelationalPath<?> entity, String clause) {
    SQLInsertClause insert = insert(entity);
    insert.addFlag(Position.END, " on duplicate key update " + clause);
    return insert;
}
Also used : SQLInsertClause(com.querydsl.sql.dml.SQLInsertClause)

Example 7 with SQLInsertClause

use of com.querydsl.sql.dml.SQLInsertClause in project querydsl by querydsl.

the class MySQLQueryFactory method insertIgnore.

/**
 * Create a INSERT IGNORE INTO clause
 *
 * @param entity table to insert to
 * @return insert clause
 */
public SQLInsertClause insertIgnore(RelationalPath<?> entity) {
    SQLInsertClause insert = insert(entity);
    insert.addFlag(Position.START_OVERRIDE, "insert ignore into ");
    return insert;
}
Also used : SQLInsertClause(com.querydsl.sql.dml.SQLInsertClause)

Example 8 with SQLInsertClause

use of com.querydsl.sql.dml.SQLInsertClause in project querydsl by querydsl.

the class LikeEscapeBase method setUp.

@Before
public void setUp() throws SQLException {
    delete(survey).execute();
    SQLInsertClause insert = insert(survey);
    insert.set(survey.id, 5).set(survey.name, "aaa").addBatch();
    insert.set(survey.id, 6).set(survey.name, "a_").addBatch();
    insert.set(survey.id, 7).set(survey.name, "a%").addBatch();
    insert.execute();
}
Also used : SQLInsertClause(com.querydsl.sql.dml.SQLInsertClause) Before(org.junit.Before)

Example 9 with SQLInsertClause

use of com.querydsl.sql.dml.SQLInsertClause in project querydsl by querydsl.

the class InsertBase method insert_with_special_options.

@Test
@IncludeIn(MYSQL)
@SkipForQuoted
public void insert_with_special_options() {
    SQLInsertClause clause = insert(survey).columns(survey.id, survey.name).values(3, "Hello");
    clause.addFlag(Position.START_OVERRIDE, "insert ignore into ");
    assertEquals("insert ignore into SURVEY (ID, NAME) values (?, ?)", clause.toString());
    assertEquals(1, clause.execute());
}
Also used : SQLInsertClause(com.querydsl.sql.dml.SQLInsertClause) Test(org.junit.Test) IncludeIn(com.querydsl.core.testutil.IncludeIn)

Example 10 with SQLInsertClause

use of com.querydsl.sql.dml.SQLInsertClause in project querydsl by querydsl.

the class InsertBase method insert_batch2.

@Test
public void insert_batch2() {
    SQLInsertClause insert = insert(survey).set(survey.id, 5).set(survey.name, "55").addBatch();
    insert.set(survey.id, 6).setNull(survey.name).addBatch();
    assertEquals(2, insert.execute());
}
Also used : SQLInsertClause(com.querydsl.sql.dml.SQLInsertClause) Test(org.junit.Test)

Aggregations

SQLInsertClause (com.querydsl.sql.dml.SQLInsertClause)52 Test (org.junit.Test)25 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)13 ExcludeIn (com.querydsl.core.testutil.ExcludeIn)6 ColumnMetadata (com.querydsl.sql.ColumnMetadata)4 MAuditDelta (com.evolveum.midpoint.repo.sql.audit.beans.MAuditDelta)3 IncludeIn (com.querydsl.core.testutil.IncludeIn)3 AuditReferenceValue (com.evolveum.midpoint.audit.api.AuditReferenceValue)2 MAuditEventRecord (com.evolveum.midpoint.repo.sql.audit.beans.MAuditEventRecord)2 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)2 H2Templates (com.querydsl.sql.H2Templates)2 QGeneratedKeysEntity (com.querydsl.sql.QGeneratedKeysEntity)2 CanonicalItemPath (com.evolveum.midpoint.prism.path.CanonicalItemPath)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 SystemException (com.evolveum.midpoint.util.exception.SystemException)1 AuditEventRecordCustomColumnPropertyType (com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordCustomColumnPropertyType)1 AuditEventRecordReferenceType (com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordReferenceType)1 AuditEventRecordReferenceValueType (com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordReferenceValueType)1 ObjectDeltaOperationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType)1