UVAshley / krank

Automatically exported from code.google.com/p/krank
0 stars 0 forks source link

Find by example query with missing getters #41

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a JPA entity that has a parameter and a corresponding setter
method but no getter method. 
2. Use this object to create a query by example

genericDao.find(like(exampleActivity));

3. A NullPointerExeption gets thrown from org.crank.crud.criteria.Example
generate() method line 101: 

Object value = pd.getReadMethod().invoke(example, (Object[]) null);

This method expects that there will be a getter method for each
PropertyDescriptor. I know that according to the Java Bean definition it is
required that getters are provided but there are sometimes reasons for them
not to be provided.

The following check worked for me to avoid the error:

if(pd.getReadMethod() == null) {
  log.debug("Excluding: " + name + " from the list of considered properties.");
  continue;
}

What version of the product are you using? On what operating system?
1.0.1
Windows XP

Original issue reported on code.google.com by vasil.ko...@gmail.com on 12 May 2009 at 10:34