Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating converters based on multiple attributes in JPA 2.1

JPA 2.1 introduced type converters. I have found examples of converters based on a single entity attribute.

Is it possible to create a type converter based on multiple entity attributes?
Are there some examples?

like image 332
cassiomolin Avatar asked Aug 06 '14 23:08

cassiomolin


2 Answers

JPA 2.2 doesn't support this feature.

If you are using Hibernate, then you can simply use a Hibernate CompositeUserType.

Hibernate gives you the flexibility of mapping one or more SQL types to specific Domain Model subtypes (e.g. Currency, Money).

like image 193
Vlad Mihalcea Avatar answered Oct 20 '22 23:10

Vlad Mihalcea


DataNucleus JPA has specific support for mapping an attribute to multiple columns, but that is not part of the JPA spec (i.e vendor extension).

There is no ability to map multiple entity attributes to one column (or to many columns).

like image 29
Neil Stockton Avatar answered Oct 21 '22 00:10

Neil Stockton