1

I have a HashMap which was populated from form elements of an HTML page, and when I save it I need Hibernate to convert it automatically to a JSON string and also persist it as a JSON string. Is this doable in Hibernate? Or, can you tell Hibernate in the mapping file (or maybe, as an annotation) to call a Java method that converts HashMap to JSON, and persist the return value of that method, and vice-versa? (read JSON string and convert automatically to a HashMap).

Thanks for all the help!

4

1 回答 1

0

当然,您可以创建自定义用户类型:

http://docs.jboss.org/hibernate/orm/3.6/reference/en-US/html/types.html#types-custom

然后 Hibernate 将使用它来将数据持久化到数据库中,并将其作为对象读回。

于 2012-07-26T10:21:15.283 回答