Some methods in our pojos model were annotated as follows:
@Column(name="cli_clipping_id", updatable=false, columnDefinition = "varchar(" + ModelUtils.ID_LENGTH + ") COLLATE utf8_bin")
The columnDefinition attribute is dependent on the database provider, so if you try to reset the schema in HSQLDB using Hibernate, this will not work:
[ERROR] 16 jun 12:58:42.480 PM main [org.hibernate.tool.hbm2ddl.SchemaExport] Unexpected token: COLLATE in statement [create table cms.edi_editorial_obj (edi_uuid varchar(23) COLLATE]
To fix this, I think of this solution (but don't want to waste time if this is not possible) at runtime for each method column annotated:
- Get @Column annotation
- Create a copy of the column annotation by setting the columnDefinition null value using javaassist.
- set the column method annotation to the copy column annotation object that overrides the old one (I don't know what is possible)
Is it possible to โcrackโ these methods in this way?
Any help would be greatly appreciated ...
source share