Tabnine Logo
SQLInsertClause.executeWithKey
Code IndexAdd Tabnine to your IDE (free)

How to use
executeWithKey
method
in
com.querydsl.sql.dml.SQLInsertClause

Best Java code snippets using com.querydsl.sql.dml.SQLInsertClause.executeWithKey (Showing top 11 results out of 315)

origin: org.everit.authentication/org.everit.authentication.oauth2.ri

private long insertProvider() {
 return querydslSupport.execute((connection, configuration) -> {
  QOAuth2Provider qoAuth2Provider = QOAuth2Provider.oAuth2Provider;
  return new SQLInsertClause(connection, configuration, qoAuth2Provider)
    .set(qoAuth2Provider.providerName, providerName)
    .executeWithKey(qoAuth2Provider.oauth2ProviderId);
 });
}
origin: com.querydsl/querydsl-sql

@Test
public void test() throws SQLException {
  stmt.execute("drop table GENERATED_KEYS if exists");
  stmt.execute("create table GENERATED_KEYS(" +
       "ID int AUTO_INCREMENT PRIMARY KEY, " +
       "NAME varchar(30))");
  QGeneratedKeysEntity entity = new QGeneratedKeysEntity("entity");
  SQLInsertClause insertClause = new SQLInsertClause(conn, new H2Templates(), entity);
  ResultSet rs = insertClause.set(entity.name, "Hello").executeWithKeys();
  ResultSetMetaData md = rs.getMetaData();
  System.out.println(md.getColumnName(1));
  assertTrue(rs.next());
  assertEquals(1, rs.getInt(1));
  assertFalse(rs.next());
  insertClause = new SQLInsertClause(conn, new H2Templates(), entity);
  rs = insertClause.set(entity.name, "World").executeWithKeys();
  assertTrue(rs.next());
  assertEquals(2, rs.getInt(1));
  assertFalse(rs.next());
  insertClause = new SQLInsertClause(conn, new H2Templates(), entity);
  assertEquals(3, insertClause.set(entity.name, "World").executeWithKey(entity.id).intValue());
  insertClause = new SQLInsertClause(conn, new H2Templates(), entity);
  assertEquals(Collections.singletonList(4), insertClause.set(entity.name, "World").executeWithKeys(entity.id));
}
origin: org.everit.resource/org.everit.resource.ri

@Override
public long createResource() {
 return querydslSupport.execute((connection, configuration) -> {
  QResource qResource = QResource.resource;
  new SQLInsertClause(connection, configuration, qResource);
  return new SQLInsertClause(connection, configuration, qResource)
    .executeWithKey(qResource.resourceId);
 });
}
origin: org.everit.blobstore/org.everit.blobstore.jdbc

@Override
public BlobAccessor createBlob() {
 Connection connection = createDatabaseConnection();
 QBlobstoreBlob qBlob = QBlobstoreBlob.blobstoreBlob;
 Long blobId;
 try {
  blobId = new SQLInsertClause(connection, this.querydslConfiguration, qBlob)
    .set(qBlob.version, 0L).set(qBlob.blob, this.emptyBlobExpression)
    .executeWithKey(qBlob.blobId);
 } catch (RuntimeException | Error e) {
  closeCloseableDueToThrowable(connection, e);
  throw new RuntimeException(e);
 }
 return updateBlob(blobId, connection, false);
}
origin: com.atlassian.plugins/atlassian-connect-core

.set(addonProperties.VALUE, value)
.set(addonProperties.UNUSED_FIELD_PRIMARY_KEY, QAddonProperty.getPrimaryKeyForProperty(addonKey, propertyKey))
.executeWithKey(addonProperties.ID);
origin: making/spring-boot-db-samples

  @Transactional
  public Pizza save(Pizza pizza) {

    Long pizzaId = sqlQueryFactory.insert(qPizza)
        .columns(qPizza.baseId, qPizza.name, qPizza.price)
        .values(pizza.getBase().getId(), pizza.getName(), pizza.getPrice())
        .executeWithKey(Long.class);

    SQLInsertClause insert = sqlQueryFactory.insert(qPizzaToppings);
    pizza.getToppings().forEach(tpg -> insert.values(pizzaId, tpg.getId()).addBatch());
    insert.execute();

    pizza.setId(pizzaId);
    return pizza;
  }
}
origin: com.querydsl/querydsl-sql

@Test
@ExcludeIn({CUBRID, SQLSERVER})
public void insert_with_keys_Projected() throws SQLException {
  assertNotNull(insert(survey).set(survey.name, "Hello you").executeWithKey(survey.id));
}
origin: com.querydsl/querydsl-sql

@Test
@ExcludeIn({CUBRID, SQLSERVER})
public void insert_with_keys_Projected2() throws SQLException {
  Path<Object> idPath = ExpressionUtils.path(Object.class, "id");
  Object id = insert(survey).set(survey.name, "Hello you").executeWithKey(idPath);
  assertNotNull(id);
}
origin: org.huiche/huiche-dao

/**
 * 新增数据
 *
 * @param entity 实体
 * @param setId  是否设置ID
 * @return ID
 */
default long create(@Nonnull T entity, boolean setId) {
  beforeCreate(entity);
  validOnCreate(entity);
  Long id = entity.getId();
  if (null == id) {
    id = sql().insert(root())
        .populate(entity)
        .executeWithKey(pk());
  } else {
    sql().insert(root())
        .populate(entity)
        .execute();
  }
  if (null == id) {
    throw new HuiCheException("新增数据失败");
  } else {
    if (setId) {
      entity.setId(id);
    }
    return id;
  }
}
origin: com.querydsl/querydsl-sql

@Test
public void insert_update_query_and_delete() {
  // Insert
  Employee employee = new Employee();
  employee.setFirstname("John");
  Integer id = insert(e).populate(employee).executeWithKey(e.id);
  assertNotNull(id);
  employee.setId(id);
  // Update
  employee.setLastname("S");
  assertEquals(1L, update(e).populate(employee).where(e.id.eq(employee.getId())).execute());
  // Query
  Employee smith = query().from(e).where(e.lastname.eq("S")).limit(1).select(e).fetchFirst();
  assertEquals("John", smith.getFirstname());
  // Delete (no changes needed)
  assertEquals(1L, delete(e).where(e.id.eq(employee.getId())).execute());
}
origin: com.querydsl/querydsl-sql

Integer id = insert(e).populate(employee).executeWithKey(e.id);
employee.setId(id);
com.querydsl.sql.dmlSQLInsertClauseexecuteWithKey

Popular methods of SQLInsertClause

  • execute
  • set
  • <init>
  • addBatch
  • columns
  • executeWithKeys
  • addFlag
  • addListener
  • clear
  • getBatchCount
  • populate
  • values
  • populate,
  • values,
  • getSQL,
  • select,
  • setBatchToBulk,
  • setNull,
  • toString

Popular in Java

  • Start an intent from android
  • setRequestProperty (URLConnection)
  • getSharedPreferences (Context)
  • addToBackStack (FragmentTransaction)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now