0

I save UUID without slashes as varbinary(16) in MySql. I will like to use annotation to map this field in Hibernate. Am I able to do it? Please help.

Here is my mapping:

@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
@Column(name = "PRODUCT_ID", unique = true) 
private String productId;

Here is my insert:

INSERT INTO `item`
(`ID`,
`TITLE`)
VALUES
(
UNHEX('f4e01440cfd011e39c1a0800200c9a66'),
'Apple' 
);

But id become something like ��%14@��%11��%1A%08%00 %0C�f in my code.

topcan5
  • 1,511
  • 8
  • 30
  • 54
  • I am writing my code based on http://stackoverflow.com/questions/10950202/how-to-store-uuid-as-number – topcan5 May 07 '14 at 03:12
  • I think this may help you http://stackoverflow.com/questions/23532492/hibernate-uuid-generation-and-mysql-uuid-function-uuid/23532603?noredirect=1#23532603 – Sagar May 08 '14 at 04:23

0 Answers0