Skip to content

Fix for Lazy load when fetched optional ManyToOne bean is null in database  #186

@rbygrave

Description

@rbygrave

I've got a unit test failing only when auto fetch data is serialized. That is when there is no serialized data it passes, subsequent runs pick up the auto tuning and it fails. I imagine you'll want a test reproducing this but I thought I'd post the trace and see if it's immediately obvious.

javax.persistence.PersistenceException: Server [null] was not found?
at com.avaje.ebean.bean.EntityBeanIntercept.loadBean(EntityBeanIntercept.java:693)
at com.avaje.ebean.bean.EntityBeanIntercept.preGetter(EntityBeanIntercept.java:793)
at com.opentempo.webapp.modeleb.Automation._ebean_get_targetPool(Automation.java:4)
at com.opentempo.webapp.modeleb.Automation._ebean_set_targetPool(Automation.java:1)
at com.opentempo.webapp.modeleb.Automation.setTargetPool(Automation.java:155)
at c
...

Nothing special...
@manytoone
@joincolumn(name = "targetpoolid")
private TargetPool targetPool;

Can you show the SQL that was executed (specifically checking if the fk column is included in the select clause)?

select t0 ..., t1.targetpoolid as c30
from ...

Target pool is nullable, and the database record contains null for targetPoolId.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions