TOP

JPA and custom data types

I even answered a guy in the Hibernate community how to map a datatype like java.net.URL and than I asked myself why some people have problems to provide them in a JPA annotated bean. It is very easy and you don’t have to implement any special JPA provider dependent interface. The solution is so easy. Break your bean down into their properties and annotate this properties as you normally do. And than – no magic – do your mapping in your getter and setter operation. Through this, you hide the information that your bean does not hold a value of your complex type. You break the type down in a setter and recreate it in the getter operation. For performance you can hold a field of your complex type and annotate it with the javax.persistence.Transient annotation.

Leave a Reply

Your email is never published nor shared.

You may use these HTML tags and attributes:<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


*