Use of Springboot JPA two

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.