One, custom query, return result map to custom class
@Query ("Select New Com.vmi.replenishment.dto.OrderReminderDTO (Arrivaltime,sum (totalnum)) from Splitorderpurchasebody WHERE shiptocode in:shiptolist GROUP by ArrivalTime ORDER by ArrivalTime ") List< Orderreminderdto> Queryorderreminderbyshipto (@Param (value= "shiptolist") list<string> shipToList);
Points:
1. The returned class implements serialization. Then you need to provide a construction method
Public classOrderreminderdtoImplementsSerializable {/**Serialversionuid*/ Private Static Final LongSerialversionuid = 1L; /*Total Data*/ //@Column (name = "Total_num") PrivateLong Totalnum; /*Arrival Date*/ //@Column (name = "Arrival_time") PrivateString ArrivalTime;
Public Orderreminderdto () {
}
Public Orderreminderdto (String Arrivaltime,long totalnum) {
This.arrivaltime = ArrivalTime;
This.totalnum = Totalnum;
}
2. Provide full path name with new on SQL statement
New Com.vmi.replenishment.dto.OrderReminderDTO
3, attributes write the properties of the class can be, do not write table field name
From is also the class name is not a table name
From Splitorderpurchasebody
ArrivalTime
4. Parameter Assignment
: Add parameter
@Param (value= "shiptolist") list<string> shiptolist
WHERE Shiptocode In:shiptolist
5. Update method
@Modifying @Transactional @Query ("Update Skuquota set huballocation =:huballocation where Skuno =: Skuno and Soldto =:soldto ") publicvoid distributebyskuandsoldto (@Param (value=) Huballocation ") string huballocation, @Param (Value=" Skuno ") string Skuno, @Param (value=" Soldto ") string SOLDTO);
There must be three annotations, or an error
Use of Springboot JPA two