Hi guys,
I'm trying to use java.util.Optional in some Persistent classes. Is there any workaround to make it work?
I have tried using UserType, but its not possible to handle something like Optional<MyPersistentClass> without mapping it to SQL types by hand (not acceptable)
I also tried to use JPA Converter, but it doesn't support Parameterized Types.
I could use wrapping getters and setters like, but it's more like a hack than a solution
Code:
public class MyClass {
private MyOtherClass other;
public Optional<MyOtherClass> getOther() {
return Optional.ofNullable(other);
}
public voud setOther(Optional<MyOtherClass> other) {
this.other = other.orElse(null);
}
}
Thanks!