I\'m trying to set up a bidirectional relationship using JPA. I understand that it\'s the responsability of the application to maintain both sides of the relationship.
Entities are Java objects. The basic rules of Java aren't changed just because there is an @Entity
annotation on the class.
So, if you instantiate an object and its constructor doesn't initialize one of the fields, this field is initialized to null.
Yes, it's your responsibility to make sure that the constructor initializes the collection, or that all the methods deal with the nullability of the field.
If you get an instance of this entity from the database (using em.find(), a query, or by navigating through associations of attached entities), the collection will never be null, because JPA will always initialize the collection.