I have the following entity class:
@Entity
public class GameSet {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private String question;
.......
}
Here is my Repository:
@Repository
public interface GameSetRepository extends CrudRepository<GameSet, Long> { }
Here is the relevant part of my Controller:
...
@RequestMapping(value = "/test/getgamesets", method = RequestMethod.GET)
public @ResponseBody Collection<GameSet> getGameSets() {
return Lists.newArrayList(gamesets.findAll());
}
...
And here is the server response:
{
"question": "Choose one of the following, which is wrong.",
"title1": "MovieA",
"title2": "MovieB",
"title3": "MovieC",
"title4": "MovieD",
"wrong": 1,
"explain": "I don't know why this is wrong.",
"rates": 0,
"rate": 0
}
I would like to get the id of the object in the request result, in addition to the other properties.
Should I override the findAll()
method?
Thanks for the attention and time!