Reputation: 99
When using Telosys to generate entities with the java7-persistence-commons-jpa-T300 templates the column annotation never includes columnDefinition when generating the @Column annotation in JpaRecord-classes. That forces database schemageneration with hbm2ddl always to generate VARCHAR columns. But when the origin database column is an CHAR-column the generated record-class should also generate columnDefinition... i.e.: @Column(columnDefinition = "CHAR(xx)", name = "VVT_NR", nullable = false, length = 20)
Is there a way to force telosys to generate the columnDefinition (with correct length for xx of course)?
Upvotes: 1
Views: 143
Reputation: 2460
The JPA function "$jpa.fieldAnnotations()” used in the mentioned template is a shortcut to generate the "classical" JPA annotations for a given field and indeed it doesn’t generated all the “@Column” optional elements (for example “table”, “insertable”, “updatable” and “columnDefinition” are not generated)
In version 3 there's no way to force the generator to produce the "columnDefinition".
But if you really want to generate the “columnDefinition” you can create a specific function or a specific macro.
To create a Velocity macro see :
To create a specific function see this other question :
For a specific function you can reuse the "$jpa" class source code :
Upvotes: 1