npryce / maybe-java

A Maybe type for Java
http://www.growing-object-oriented-software.com
Apache License 2.0
70 stars 18 forks source link

Hibernate user type for storing Maybe<T> values #2

Open npryce opened 13 years ago

npryce commented 13 years ago

unknown -> null known -> actual value

nespera commented 13 years ago

The user type needs to return the JDBC types used to map the given class to the database. But due to type erasure when Hibernate is presented with a Maybe<String> it will appear at runtime to be just a Maybe. So this looks to me to be a much harder problem than just writing a User Type.

npryce commented 13 years ago

You'll need to configure the wrapped type in the mapping for the property. I've done it for other types. It's a minor pain but does work.