@Test public void insertOnDuplicateKeyUpdate2() { SQLInsertClause clause = queryFactory.insertOnDuplicateKeyUpdate(QSurvey.survey, QSurvey.survey.id.eq(2)); assertEquals( "insert into SURVEY\nvalues () on duplicate key update SURVEY.ID = ?", clause.toString()); }
@Test public void insertOnDuplicateKeyUpdate_null() { SQLInsertClause clause = queryFactory.insertOnDuplicateKeyUpdate( QSurvey.survey, SQLExpressions.set(QSurvey.survey.name, (String) null)); assertEquals( "insert into SURVEY\n" + "values () on duplicate key update SURVEY.NAME = null", clause.toString()); }
@Test public void insertOnDuplicateKeyUpdate_multiple() { SQLInsertClause clause = queryFactory.insertOnDuplicateKeyUpdate( QSurvey.survey, SQLExpressions.set(QSurvey.survey.id, 2), SQLExpressions.set(QSurvey.survey.name, "B")); assertEquals( "insert into SURVEY\n" + "values () on duplicate key update SURVEY.ID = ?, SURVEY.NAME = ?", clause.toString()); }
private void savePredictionHistory( Long predictorId, DateTime start, List<Prediction> predictions) { if (!predictions.isEmpty()) { final SQLInsertClause insert = queryFactory.insert(qPredictionHistory); predictions.forEach( p -> insert .set(qPredictionHistory.predictorId, predictorId) .set( qPredictionHistory.forecastDistanceInMinutes, ((int) new Duration(start, p.timestamp).getStandardMinutes())) .set(qPredictionHistory.ts, p.timestamp) .set(qPredictionHistory.spacesAvailable, p.spacesAvailable) .addBatch()); insert.execute(); } }
@Test public void insertIgnore() { SQLInsertClause clause = queryFactory.insertIgnore(QSurvey.survey); assertEquals("insert ignore into SURVEY\nvalues ()", clause.toString()); }