org.fluentjdbc.DatabaseSaveBuilderWithoutGeneratedKeys Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fluent-jdbc Show documentation
Show all versions of fluent-jdbc Show documentation
A Java library used to execute JDBC statements and build SQL
package org.fluentjdbc;
import javax.annotation.Nullable;
import java.sql.Connection;
/**
* Subclass of {@link DatabaseSaveBuilder} which assumes the client code always specifies
* primary key field
*/
public class DatabaseSaveBuilderWithoutGeneratedKeys extends DatabaseSaveBuilder {
public DatabaseSaveBuilderWithoutGeneratedKeys(DatabaseTableImpl table, String idField, T id) {
super(table, idField, id);
}
@Override
@Nullable
protected T insert(Connection connection) {
DatabaseInsertBuilder builder = table.insert();
if (idValue != null) {
builder = builder.setField(idField, idValue);
}
builder
.setFields(fields, values)
.setFields(uniqueKeyFields, uniqueKeyValues)
.execute(connection);
return idValue;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy