|
I'm trying to use an Java enum and save it as a String in the database. Problem is that it doesn't work. When validating database against java entities it triggers an error :
org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [nature] in table [address_level]; found varchar (Types#VARCHAR), but expecting bytea (Types#VARBINARY)
I managed to overcome that error putting the column definition to columnDefinition = "varchar".
Then when we try to saves, istead of saving "List", it saves weird data such as "\xaced00057e72002a636f6d2e7374692e61646472657373656e7469746965732e656e756d65726174696f6e2e4e617475726500000000000000001200007872000e6a6176612e6c616e672e456e756d000000000000000012000078707400044c495354"
Here's my enum: public enum Nature { LIST, EXLIST, INPUT }
Field definition in my entity: @Column(columnDefinition = "varchar", nullable = false, length = 100) @Enumerated(EnumType.STRING) private Nature nature;
database field definition:
CREATE TABLE address_level ( id character varying(36) NOT NULL, nature character varying(100) NOT NULL, CONSTRAINT pk_address_level PRIMARY KEY (id), )
tried the same setup on an Oracle Database and it works as expected (with version 4.3.8)
|