spring-attic / spring-cloud-gcp

Integration for Google Cloud Platform APIs with Spring
Apache License 2.0
705 stars 693 forks source link

NullPointerException when passing the null value for nullable column #2443

Closed takithon closed 4 years ago

takithon commented 4 years ago

Version

both spring-cloud-gcp-data-spanner-1.2.0.RELEASE and 1.2.1.RELEASE. Only I checked.

What I did

I used @Query annotation and DML statement, then pass the null value for the nullable column.

What was occurred

NullPointerException at SqlSpannerQuery.

What I was expected

I want to input null value in the table if I passed null value to the method and the column is nullable.

Situation the phenomena occurs

Assume that lastName is the nullable column at the singer table.

Define a method like below at the repository with extends of SpannerRepository

@Query(dmlStatement = true, value = "INSERT INTO singer (singer_id, birth_date, first_name, last_name) VALUES (@singerId, @birthDay, @firstName, @lastName)")
public void insert(Integer singerId, Date birthDay, String firstName, String lastName);

Then use it like below

xxxRepository.insert(3, Date.valueOf(LocalDate.of(1994, 12, 27)), "first_name", null);
dzou commented 4 years ago

Thanks for reporting the issue, I think I have a fix for this.

takithon commented 4 years ago

Thank you for corresponding it. I'm going to continue to watch the PR.