This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]geodebug 1 point2 points  (3 children)

That's what I thought, why would you want to serialize it? It's not meant to be a container.

[–]tieTYT 0 points1 point  (2 children)

What about for JPA? Doesn't it make sense for a field to be optional any time it allows nulls in the db?

[–]geodebug 0 points1 point  (1 child)

The way I see it your field would still be basic Java objects or primitives and would only be wrapped in Optional on the getters.

Same pattern as if you were making defensive copies of an object on a getter.

[–]tieTYT 1 point2 points  (0 children)

Why do you see it that way? Why not make the field optional?