diff --git a/jirm-orm/src/main/java/co/jirm/mapper/definition/SqlParameterDefinition.java b/jirm-orm/src/main/java/co/jirm/mapper/definition/SqlParameterDefinition.java index e9f06e4..9f5f3d6 100644 --- a/jirm-orm/src/main/java/co/jirm/mapper/definition/SqlParameterDefinition.java +++ b/jirm-orm/src/main/java/co/jirm/mapper/definition/SqlParameterDefinition.java @@ -36,7 +36,9 @@ import javax.persistence.Version; import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; import static co.jirm.core.util.JirmPrecondition.check; import co.jirm.mapper.SqlObjectConfig; @@ -117,6 +119,24 @@ public Object convertToSql(Object original) { static Map getSqlBeanParameters(Class k, SqlObjectConfig config) { Map parameters = new LinkedHashMap(); + + final JsonIdentityInfo classIdentityInfo = k.getAnnotation(JsonIdentityInfo.class); + if (classIdentityInfo != null && classIdentityInfo.generator() == ObjectIdGenerators.IntSequenceGenerator.class) { + final String idName = classIdentityInfo.property(); + final SqlParameterDefinition parameterDefinition = newSimpleInstance( + config.getConverter(), + idName, + Integer.class, + -1, + config.getNamingStrategy().propertyToColumnName(idName.replaceAll("^@", "meta_")), + true, + false, + true, + Optional.absent()); + + parameters.put(idName, parameterDefinition); + } + Constructor cons[] = k.getDeclaredConstructors(); for (Constructor c : cons) { JsonCreator jc = c.getAnnotation(JsonCreator.class);