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 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