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 javax.annotation.ParametersAreNonnullByDefault;
import java.time.Instant;
import java.util.List;
@ParametersAreNonnullByDefault
public class DatabaseTableWithTimestamps extends DatabaseTableImpl {
public DatabaseTableWithTimestamps(String tableName) {
super(tableName);
}
@Override
public DatabaseInsertBuilder insert() {
Instant now = Instant.now();
return super.insert()
.setField("updated_at", now)
.setField("created_at", now);
}
@Override
public DatabaseBulkInsertBuilder bulkInsert(Iterable objects) {
return super.bulkInsert(objects)
.setField("updated_at", t -> Instant.now())
.setField("created_at", t -> Instant.now());
}
@Override
public DatabaseBulkUpdateBuilder bulkUpdate(List objects) {
return super.bulkUpdate(objects).setField("updated_at", t -> Instant.now());
}
@Override
public DatabaseUpdateBuilder update() {
return super.update().setField("updated_at", Instant.now());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy