/** * Execute the clause and return the generated key cast to the given type. * If no rows were created, null is returned, otherwise the key of the first row is returned. * * @param <T> * @param type type of key * @return generated key */ public <T> T executeWithKey(Class<T> type) { return executeWithKey(type, null); }
/** * Execute the clause and return the generated key with the type of the given path. * If no rows were created, null is returned, otherwise the key of the first row is returned. * * @param <T> * @param path path for key * @return generated key */ @SuppressWarnings("unchecked") @Nullable public <T> T executeWithKey(Path<T> path) { return executeWithKey((Class<T>) path.getType(), path); }
@Test @ExcludeIn({H2, CUBRID, SQLSERVER}) public void merge_with_keys_Projected() throws SQLException { assertNotNull(merge(survey).keys(survey.id) .set(survey.id, 8) .set(survey.name, "Hello you").executeWithKey(survey.id)); }
@Test @ExcludeIn({H2, CUBRID, SQLSERVER}) public void merge_with_keys_Projected2() throws SQLException { Path<Object> idPath = ExpressionUtils.path(Object.class, "id"); Object id = merge(survey).keys(survey.id) .set(survey.id, 9) .set(survey.name, "Hello you").executeWithKey(idPath); assertNotNull(id); }