hibernate-reactive icon indicating copy to clipboard operation
hibernate-reactive copied to clipboard

Add test for `@NotFound` annotation

Open DavideD opened this issue 2 years ago • 11 comments

See this PR for ORM: https://github.com/hibernate/hibernate-test-case-templates/pull/159

DavideD avatar Apr 26 '22 08:04 DavideD

Hey, I will take a look on this one

encircled avatar Apr 26 '22 17:04 encircled

Thanks. If it doesn’t work for ORM it probably doesn’t work for us as well. A test is what we need to begin with.

please, use this templates for the code: https://github.com/hibernate/hibernate-ide-code styles

the templates for Hibernate ORM.

DavideD avatar Apr 27 '22 07:04 DavideD

@DavideD Indeed, can confirm it behaves the same regardless of @NotFound.

There is one more cases with broken reference I'm not 100% sure about, @JoinColumn(nullable = false) + @NotFound(action = NotFoundAction.IGNORE) + @ManyToOne(optional = true). It will throw an exception 'not-null property references a null or transient value' due to 'nullable = false'. This is a weird case thou..

encircled avatar Apr 27 '22 08:04 encircled

I think the behaviour in this case makes sense. There is not an error because of the entity not being found (so NotFoundAction.IGNORE is respected). The error happens because of nullable=false. Anyway, I don't think this is a realistic scenario or something critical.

That said, I haven't checked the javadoc for @NotFound so I'm not sure which cases is supposed to cover at the moment.

DavideD avatar Apr 27 '22 08:04 DavideD

This is to be fixed in ORM and then we merge the unit test, right?

encircled avatar Apr 27 '22 08:04 encircled

Probably. Sometimes we don't use the code in ORM directly, we need to adapt it. So it depends from what the fix looks like. But it makes sense to wait for the fix in ORM.

DavideD avatar Apr 27 '22 08:04 DavideD

Ok, so I will follow up after that

encircled avatar Apr 27 '22 09:04 encircled

@DavideD seems that it was fixed in ORM in 6.x, any plans for migration yet?

encircled avatar May 25 '22 07:05 encircled

@blafond Any update on this?

DavideD avatar May 25 '22 10:05 DavideD

One thing to watch out for here: the semantics of @NotFound changed a lot in H6 IIRC. So we might not want to spend too much effort on writing tests for the old behavior, which might not even have been very well-specified.

gavinking avatar Jun 06 '22 11:06 gavinking

k... I can live with that.

blafond avatar Jun 06 '22 12:06 blafond