FasterXML / jackson-datatype-hibernate

Add-on module for Jackson JSON processor which handles Hibernate (https://www.hibernate.org/) datatypes; and specifically aspects of lazy-loading
319 stars 106 forks source link

Ignore missing entities when lazy loading is enabled with new `Feature.WRITE_MISSING_ENTITIES_AS_NULL` #126

Closed mobreza closed 5 years ago

mobreza commented 5 years ago

This minor update gets around "Unable to find ... with id ..." of EntityNotFoundException when enable(Feature.WRITE_MISSING_ENTITIES_AS_NULL).

Fixes #125.

cowtowncoder commented 5 years ago

In general I am not big fan of quietly swallowing exceptions, but since this is an opt-in feature covering a real use case that seems reasonable.

Just one request: looks like you only added this for hibernate4 module. Could you please do the same for hibernate5 as well? (hibernate3 is optional as far as I am concerned, may add if you want to, but it is not widely used).

mobreza commented 5 years ago

@cowtowncoder Updated Hib5 module as requested, but as I only use 4, I have not tested it.

mobreza commented 5 years ago

@cowtowncoder As usual, I need this in production yesterday 😄. Please let me know what I can do to make this happen.

cowtowncoder commented 5 years ago

@mobreza Understandable :)

Thank you for adding hibernate5 part.

Now... on timing. You will probably need to compile and use local snapshot for one reason: even if I merge this soon (which I plan to), it will have to go in a minor release, adding new functionality. But 2.10.0 is not ready to go yet at this point (actually neither would 2.9.9 be), so getting to pre-release / release candidate will take a while.

As to merging: would it be easy/possible to write a unit test to verify this functionality? I know there are tests that create in-memory database, run tests against Hibernate. But I don't know if testing this particular feature is feasible or not -- but would be great if it could. If not, just let me know, I can merge this without test(s) if need be.

mobreza commented 5 years ago

@cowtowncoder Added unit tests as requested.

mobreza commented 5 years ago

@cowtowncoder Using space indentation.

cowtowncoder commented 5 years ago

Excellent! Thank you very much for doing this.