[hibernate-dev] Embedded value not null when it includes an @ElementCollection

Steve Ebersole steve at hibernate.org
Thu Sep 18 10:15:58 EDT 2014


I have not played with case specifically, but it makes sense.  ORM tries
hard to never return a null collection reference.

On Wed, Sep 17, 2014 at 10:31 AM, Davide D'Alto <daltodavide at gmail.com>
wrote:

> Hi,
> I've created a test for OGM where we store an @Embeddable containing a list
> annotated with @ElementCollection [1]:
>
> This is the embedded:
>
> @Embeddable
> public class PhoneNumber {
>
>     private String main;
>
>     @ElementCollection
>     private List<String> alternatives;
>
> ...
>
> }
>
> In the test [2] I first save an entity with the embedded attribute set to
> null and then I call a session.get(...) to obtain it. The embedded
> attribute is not null as I was expecting.
>
> The same this happend when I've tried it on ORM, is this the expected
> behaviour?
>
> Thanks,
> Davide
>
> [1]
>
> https://github.com/hibernate/hibernate-ogm/blob/8a8b29f660973cad4c340931c4dcf9536342721b/core/src/test/java/org/hibernate/ogm/backendtck/embeddable/PhoneNumber.java
>
> [2]
>
> https://github.com/hibernate/hibernate-ogm/commit/bfed4e2df06f18960502af24fea72d45c1002fe7#diff-024806c2656dbe23ae1a5526f3a6845fR195
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>


More information about the hibernate-dev mailing list