Hi Henno, The JPA spec is not prescriptive on the behavior in this case. You annotated the relationship to be not optional, but since you already have rows in the database table that contain null values, we don't flag this as an error. Other providers may have different behavior. In many cases, this "optional" flag is used when generating database schemas in order to generate the proper constraints.
Kevin On Fri, Mar 11, 2011 at 9:52 AM, Henno Vermeulen <[email protected]>wrote: > Hello, > > I have an entity with a column that is annotated with @ManyToOne(optional = > false). The corresponding database table has a row that contains null for > his column. When I try to find this entity by it's correct id using > entityManager.findById, it returns null. > > Is this expected behavior? I would have expected an error message. > > Regards, > Henno Vermeulen > Huize Molenaar >
