vladmihalcea / high-performance-java-persistence

The High-Performance Java Persistence book and video course code examples
Apache License 2.0
1.31k stars 489 forks source link

Json type doesn't supports generic type #2

Closed quaff closed 8 years ago

quaff commented 8 years ago

https://vladmihalcea.com/2016/06/20/how-to-map-json-objects-using-generic-hibernate-types/ @Type(type = "json") @Column(columnDefinition = "json") private Location location; works fine. @Type(type = "json") @Column(columnDefinition = "json") private List<Location> locations; will failed. ( (ParameterType) parameters.get( PARAMETER_TYPE ) ).getReturnedClass() should return ParameterizedType instead of Class. Maybe AttributeConverter is a better solution.

vladmihalcea commented 8 years ago

It's intended to be like that because PostgreSQL and MySQL allow you to save a single root JSON object. Mapping a list of JSON objects is not, therefore, supported.