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

Allow deserialization of null Object Id #742

Closed
cowtowncoder opened this issue Mar 30, 2015 · 2 comments
Closed

Allow deserialization of null Object Id #742

cowtowncoder opened this issue Mar 30, 2015 · 2 comments

Comments

@cowtowncoder
Copy link
Member

(note: related to FasterXML/jackson-annotations#56)

For some use cases (one known case being use from ORM like Hibernate) it makes sense to allow use of null (or missing) Object Id, in cases where actual Id will be generated by something other than Jackson. It may also make sense to add matching DeserializationFeature which allows such a condition to either be acceptable (default), or not (throw an exception), to allow for strict checks in cases where null/missing Object Id is not a legal use case.

@cowtowncoder
Copy link
Member Author

Looks like missing Object id was acceptable already, as per tests.

cowtowncoder added a commit that referenced this issue Apr 2, 2015
@leolozes
Copy link

leolozes commented Mar 2, 2016

In the ObjectIdValueProperty class, the check you added to the deserializeSetAndReturn function:

if (id == null) {
    return null;
}

Is positioned after the Object id = _valueDeserializer.deserialize(p, ctxt);.

Could it be that it should be positioned before the deserialization? If we don't change it, we have exceptions like this one:
JsonMappingException: Can not deserialize instance of java.lang.String out of VALUE_NULL
when we send a JSON with a null id, with this annotation:
JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")

Or are we simply doing something wrong here?

Thanks

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

2 participants