spring-projects / spring-projects/spring-data-rest

Performing a "Modifying query" generates an error

Open
#104 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

The execution of a "Modifying query", defined as follows:

public interface EventoCalendarioRepository extends JpaRepository<EventoCalendario, Integer> {
@Transactional
@Modifying
@Query("update EventoCalendario ec set ec.dataEstinzione = null, ec.ottemperato = false where ec.id = :id")
Integer resetStatoEvento(@Param("id") Integer id);
}

invoking the url with the GET method:
http://localhost:8080/laweb4/eventoCalendario/search/resetStatoEvento?id=55074

generates a response with error:
Request URL:http://client-wi7-rzu2:8080/laweb4/eventoCalendario/search/resetStatoEvento?id=55074
Request Method:GET
Status Code:400 Bad Request
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Encoding:gzip,deflate,sdch
Accept-Language:it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Cookie:JSESSIONID=9436BEBA86AC23EA6286FB5F7C23A50F
Host:client-wi7-rzu2:8080
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.37 Safari/537.36
Query String Parametersview sourceview URL encoded
id:55074
Response Headersview source
Connection:close
Content-Encoding:gzip
Content-Type:application/json
Date:Thu, 06 Jun 2013 12:17:20 GMT
Server:Apache-Coyote/1.1
Transfer-Encoding:chunked
Vary:Accept-Encoding

with this response:
{"cause":null,"message":"java.lang.ClassCastException@453fd696"}

N.B.
The command to update the db is successful


To me it seems a bug, what do you think?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the EventoCalendarioRepository.resetStatoEvento method and the /eventoCalendario/search/resetStatoEvento route described in the report. Reproduce the GET request with id=55074, then trace how the successful modifying-query result is converted into the HTTP response; done means the update still succeeds without the reported ClassCastException and the endpoint returns a valid response.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.