openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Sutter <>
Subject Re: entityManager.find returns null (even if a row with the exact id exists in the database)
Date Fri, 11 Mar 2011 17:27:47 GMT
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.


On Fri, Mar 11, 2011 at 9:52 AM, Henno Vermeulen <>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

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message