Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/Change: HibernateProxy in property annotated with @JsonIdentityInfo @JsonReference(alwaysId=true) #124

Open
f-aubert opened this issue Oct 31, 2018 · 0 comments

Comments

@f-aubert
Copy link

Hello,

I'm facing the following the challenge I have an Entity which has a Lazy parent entity which I want to always be serialised by Id. If by any chance the Parent Entity is uninitialised and proxied, then I will get null instead of the id in JSON.

Here is an example:
// jsonidentity referring to id property
Entity {
// id
Long id;
// lazy
// jsonreference alwaysId=true
Entity parent;
}

which I expected to be serialised in Json like this:
{
id: 10,
parent: 1
}

A possibility would be to use the feature SERIALIZE_IDENTIFIER_FOR_LAZY_NOT_LOADED_OBJECTS, but it will create an object with a property id where I only want the id as it unwrapped. So I see two solutions,

  1. making another feature "SERIALIZE_UNWRAPPED_IDENTIFIER_FOR_LAZY_NOT_LOADED_OBJECTS, 2) handling the NULLS in either the HibernateProxySerializer.serialize Method or HibernateProxySerializer.findProxied Method to always return init.getIdentifier() when initialised instead of null.

What are your thoughts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant