The following JPA column definition generates an "integer" data type by default on all databases (e.g. h2, mysql, postgres)
@Column(name = "type", nullable = false)
@Type(type = "com.mycompany.hibernate.usertype.GenericEnumUserType", parameters = {
@Parameter(name = "enumClass", value = "com.mycompany.model.DegreeType"),
@Parameter(name = "identifierMethod", value = "toInt"),
@Parameter(name = "valueOfMethod", value = "fromInt") })
@NotNull
private DegreeType type;
I would like to use minimal storage for this field and hence would prefer to use the columnDefinition parameter for schema2ddl generation. But looks like tinyint is not supported in postgres, but is supported in other databases mentioned above.
Would it be possible to generate different SQL files based on the database type. 1. What would be the best approach to acheive this? 2. What would be the best data type (with minimal storage) which can be used for this purpose? Would that be smallint