-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: java.util.Optional is possible to support it?
PostPosted: Sat Jul 26, 2014 5:34 pm 
Newbie

Joined: Sat Jul 26, 2014 5:18 pm
Posts: 1
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.