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

SQL - Mapper implementations suffer from NullPointerException potentially #96

Closed
odrotbohm opened this issue Feb 8, 2012 · 1 comment
Closed

Comments

@odrotbohm
Copy link

@odrotbohm odrotbohm commented Feb 8, 2012

Assume you have a domain class containing a property which doesn't have a corresponding metadata element in the query class. If an object of such a class is passed to a Mapper implementation (seems to be the case for all of them) you'll get a NullPointerException at the following code snippet (taken from DefaultMapper but the other implementations suffer from the same issue):

Map<String, Field> fields = getPathFields(entity.getClass());
…
Field field = fields.get(property);
Path path = (Path<?>) field.get(entity);
if (entry.getValue() != null) {
  values.put(path, entry.getValue());    
}

field will be null for the property mapped in the domain object but not included in the query class. So I think the relevant code snippet has to be changed to:

Field field = fields.get(property);

if (field != null && entry.getValue() != null) {
  Path path = (Path<?>) field.get(entity);
  values.put(path, entry.getValue());    
}

This is also avoiding the path lookup if not necessary although this is probably just a cosmetic issue.

timowest added a commit that referenced this issue Feb 8, 2012
@timowest
Copy link
Member

@timowest timowest commented Feb 19, 2012

released in 2.3.2

@timowest timowest closed this Feb 19, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants