Issue Details (XML | Word | Printable)

Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Unassigned
Reporter: Florian Schmitt
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.
DataNucleus Store RDBMS

NullPointerException when setting multiple Date parameters

Created: 28/Jul/14 05:50 PM   Updated: 10/Aug/14 12:57 PM   Resolved: 30/Jul/14 03:02 PM
Component/s: None
Affects Version/s: 4.0.1
Fix Version/s: 4.0.2

Environment: Windows 7 64bit, Java 1.8.0_05

Datastore: MySQL
Severity: Production

 Description  « Hide
Im getting a NullPointerException when setting multiple Date parameters on an JPA single string query.

(why cant I attach files here?) [additionally the link 'this guide' below this box is not working...]

Here is a test entity:

@Table(name = "test_date")
@TableGenerator(name = "test_date_id", allocationSize = 1)
public class TestDate implements Serializable

private static final long serialVersionUID = 1L;

@GeneratedValue(strategy = GenerationType.TABLE, generator = "test_date_id")
@Basic(optional = false)
@Column(name = "id", nullable = false)
private Long id;

@Basic(optional = false)
@Column(name = "date", nullable = false)
private Date date;

@Basic(optional = false)
@Column(name = "date2", nullable = false)
private Date date2;


The following query works:

entityManager.createQuery("Select x From TestDate x Where = :date", TestDate.class)//
.setParameter("date", dateValue) //
.getResultList(); //

This query does not work anymore:

entityManager.createQuery("Select x From TestDate x Where = :date And x.date2 = :date2", TestDate.class)//
.setParameter("date", dateValue) //
.setParameter("date2", dateValue) //
.getResultList(); //

This is the stacktrace:

Caused by: java.lang.NullPointerException
at java.lang.String.valueOf(
at java.lang.StringBuilder.append(
at org.datanucleus.query.evaluator.AbstractExpressionEvaluator.compileRelationalExpression(
at org.datanucleus.query.evaluator.AbstractExpressionEvaluator.compileOrAndExpression(
at org.datanucleus.query.evaluator.AbstractExpressionEvaluator.evaluate(
at org.datanucleus.query.expression.Expression.evaluate(
at org.datanucleus.query.expression.DyadicExpression.evaluate(
at org.datanucleus.query.expression.DyadicExpression.evaluate(
at org.datanucleus.api.jpa.JPAQuery.setParameter(

This actually happens at the time the first parameter is set, so thats why the second parameter is still null...

Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 28/Jul/14 07:01 PM
"this guide" link fixed thx, but then it is quoted in all docs, forum, JIRA front page etc.

Why you can't attach files only you can answer. I can. Others can.

Florian Schmitt added a comment - 29/Jul/14 12:10 PM
Ok, I got it now, thanks! It seems you can't attach file at the time, when you report a bug, but only afterwards... I didn't know that.

Here is the test case:

Andy Jefferson added a comment - 30/Jul/14 03:02 PM
GitHub master simply changes the toString to check for null value.