Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
package eu.f3rog.db;
import com.j256.ormlite.field.FieldType;
import com.j256.ormlite.field.SqlType;
import com.j256.ormlite.field.types.BaseDataType;
import java.sql.SQLException;
* Class {@link CompositeIdFieldPersister} is used for persisting / retrieving {@link TimeStamp} objects to / from database.
* @author Frantisek Gazo
* @version 2015-09-09
public class CompositeIdFieldPersister extends BaseDataType {
private static final CompositeIdFieldPersister instance = new CompositeIdFieldPersister();
private CompositeIdFieldPersister() {
super(SqlType.STRING, new Class<?>[]{TimeStamp.class});
public static CompositeIdFieldPersister getSingleton() {
return instance;
public Object javaToSqlArg(FieldType fieldType, Object javaObject) {
if (javaObject == null) {
return null;
} else {
return javaObject.toString();
public Object sqlArgToJava(FieldType fieldType, Object sqlArg, int columnPos) throws SQLException {
return CompositeId.Builder.buildFrom((String) sqlArg);
public Object resultToSqlArg(FieldType fieldType, DatabaseResults results, int columnPos) throws SQLException {
return results.getString(columnPos);
public Object parseDefaultString(FieldType fieldType, String defaultStr) throws SQLException {
return defaultStr;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment