Thursday 15 March 2012

hibernate - hbm2ddl on a column based on GenericEnumUserType -


The following JPA column definition generates an "integer" data type by default on all databases (like H2, mysql, postgres )

  @Column (name = "type", nullable = false) @ type ("type =" com.mycompany.hibernate.usertype.GenericEnumUserType ", parameter = {@Parameter (name = "EnumClass", value = "com.mycompany.model.DegreeType"), @Parameter (name = "identifierMethod", value = "toInt"), @Parameter (name = "valueOfMethod", value = "fromInt"}}) @NotNull Private degree type type;  

I would like to use the minimum storage for this field and therefore This schema would prefer to use the columnDefinition parameter for the 2nd generation generation but it seems that the tintint is not supported in postgrave, but is supported in other databases mentioned above.

What is different depending on the database type Will it be possible to generate separate SQL files? 1. What is the best way to get it? 2. What will be the best data type (with minimal storage) C can be used for this purpose? Since you are using a custom type (why?), The definition of the underlying column (

"post-text" itemprop = "text">

S) your type of sqlTypes () will be generated on the basis of the result of the actual SQL column type will be derived from the appropriate colloquial .

And mounts from H2 / MySQL to tint .

Everyone said, I use generally :

  1. using @nomized annotations.
  2. Store value value preserves some space using the string instead of integer , but it identifies a major problem: 3 months below the line (Year) Any person changes the code by inserting another NM constant between your type and suddenly all your data becomes invalid Disk space is cheap; There is no such deal with issues. @Enumerated (EnumType.STRING) @ column (name = "degree_type", tap = incorrect, length = 0!) Personal degree type;


No comments:

Post a Comment