org.fluentjdbc.DatabaseSaveBuilderWithUUID 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 java.sql.Connection;
import java.sql.SQLException;
import java.util.UUID;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
@ParametersAreNonnullByDefault
public class DatabaseSaveBuilderWithUUID extends DatabaseSaveBuilder {
public DatabaseSaveBuilderWithUUID(DatabaseTableImpl table, String idField, @Nullable UUID idValue) {
super(table, idField, idValue);
}
@Override
@Nullable
protected UUID insert(Connection connection) {
UUID idValue = this.idValue;
if (idValue == null) {
idValue = UUID.randomUUID();
}
table.insert()
.setFields(fields, values)
.setField(idField, idValue)
.setFields(uniqueKeyFields, uniqueKeyValues)
.execute(connection);
return idValue;
}
@Override
protected UUID getId(DatabaseRow row) throws SQLException {
return UUID.fromString(row.getString(idField));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy