0

I use varbinary(36) to save UUID in MySql as primary keys. And I use EclipseLink to auto gen my data objects. It gens primary key as String. I inserted data as below. When I use JPA to select * from country, the COUNTRY_ID becames: '66653565373765302D663832312D313165332D613361632D303830303230306339613636'. What am I doing wrong?

INSERT INTO `didicity`.`country`
(`COUNTRY_ID`, `NAME`, `SHORT_NAME`)
VALUES
('fe5e77e0-f821-11e3-a3ac-0800200c9a66', 
'United State',
'USA'
);



@Id
@Column(name = "COUNTRY_ID")
private String countryId;
topcan5
  • 1,511
  • 8
  • 30
  • 54
  • The value that has been returned appears to be the hexadecimal equivalent of the value that you inserted. That's not completely surprising given that it's a var __binary__ column. – Steve C Aug 12 '14 at 02:26
  • What should I do to make them in sync? convert them? I need to run select where from db by using that key. – topcan5 Aug 12 '14 at 03:17
  • Perhaps the answer here [How to store uuid as number](http://stackoverflow.com/questions/10950202/how-to-store-uuid-as-number) will help you out? – Steve C Aug 12 '14 at 03:31
  • Thx Steve C! If i need to save UUID as varbinary(36) in MySQL, is there anything in Java code I can do to make it work? – topcan5 Aug 12 '14 at 04:39

0 Answers0