All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fluentjdbc.DatabaseTableWithTimestamps Maven / Gradle / Ivy

There is a newer version: 0.5.3
Show newest version
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