In Spring Data JPA, the @Query annotation is typically used for defining custom queries for reading data from the database. While it's not intended for update operations, you can achieve update functionality using @Query in combination with the @Modifying annotation.
I would like to understand how do I compare two fields in the document. Has anyone ever needed to do this type of comparison? I'm using the criteria. criteria.add(Criteria.where("this.campoC == this.campoD")); Query query = new Query(); List criteria = new ArrayList(); criteria.add(Criteria.where("campoA").is(123)); criteria.add(Criteria.where("campoB").is("N")); criteria.add(Criteria.where("this.campoC == this.campoD")); //
Great Work 👍
Thank u for video, i feel you need to explain the use case whihc you want to demo in video,then end use(group by case was not clear.
thanku
Please share the sample code for this tutorial.
wow u told lot many ,is there any complete list of when to use which, i felt it is small lecture, can u do big detailed lecture
Sure
How to write case insensitive query
Haven't seen any criteria queries...
Increase your volume please
Can we use @Query for update also ??
In Spring Data JPA, the @Query annotation is typically used for defining custom queries for reading data from the database. While it's not intended for update operations, you can achieve update functionality using @Query in combination with the @Modifying annotation.
where is github link?
I would like to understand how do I compare two fields in the document. Has anyone ever needed to do this type of comparison? I'm using the criteria.
criteria.add(Criteria.where("this.campoC == this.campoD"));
Query query = new Query();
List criteria = new ArrayList();
criteria.add(Criteria.where("campoA").is(123));
criteria.add(Criteria.where("campoB").is("N"));
criteria.add(Criteria.where("this.campoC == this.campoD")); //
@GetMapping("/")
List compareName(@PathVariable(value = "name") String name,@PathVariable(value = "name2") String name2){
Query query = new Query();
query.addCriteria(Criteria.where(name).elemMatch(Criteria.where(name)));
return mongoTemplate.find(query,EmployeeModel.class);
}
Can you please add this code into GitHub
explain update query