org.fluentjdbc.DatabaseTableWithTimestamps 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 org.joda.time.DateTime;
import java.util.List;
import javax.annotation.ParametersAreNonnullByDefault;
@ParametersAreNonnullByDefault
public class DatabaseTableWithTimestamps extends DatabaseTableImpl implements DatabaseTable {
public DatabaseTableWithTimestamps(String tableName) {
super(tableName);
}
@Override
public DatabaseInsertBuilder insert() {
DateTime now = DateTime.now();
return super.insert()
.setField("updated_at", now)
.setField("created_at", now);
}
@Override
public DatabaseBulkInsertBuilder newBulkInserter(List objects, String... fieldNames) {
DatabaseBulkInsertBuilder builder = super.newBulkInserter(objects, fieldNames);
builder.addFieldNames("updated_at", "created_at");
return builder;
}
@Override
public DatabaseUpdateBuilder update() {
return super.update().setField("updated_at", DateTime.now());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy