package com.teamid.repository;

import com.teamid.entity.OrderRecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by Skye on 2017/6/3.
 */
public interface OrderRecordRepository extends JpaRepository<OrderRecord, Long> {

    List<OrderRecord> findOrderRecordsByCustomerId(long customerId);

    List<OrderRecord> findOrderRecordsByPartnerId(long partnerId);

    OrderRecord findOrderRecordByPartnerTicketId(long partnerTicketId);

    @Modifying
    @Query(value = "update order_record o set o.partnerId = ?2 where o.id = ?1"
    , nativeQuery = true)
    void modifyOrderRecordWithPartnerId(long id, long parnetId);

    @Modifying
    @Query(value = "update order_record o set o.status = ?2 where o.id = ?1"
    , nativeQuery = true)
    void modifyOrderRecordWithStatus(long id, int status);

}

package com.teamid.repository;

import com.teamid.entity.OrderRecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by Skye on 2017/6/3.
 */
public interface OrderRecordRepository extends JpaRepository<OrderRecord, Long> {

    List<OrderRecord> findOrderRecordsByCustomerId(long customerId);

    List<OrderRecord> findOrderRecordsByPartnerId(long partnerId);

    OrderRecord findOrderRecordByPartnerTicketId(long partnerTicketId);

    @Modifying
    @Query(value = "update order_record o set o.partner_id = ?2 where o.id = ?1"
    , nativeQuery = true)
    void modifyOrderRecordWithPartnerId(long id, long parnetId);

    @Modifying
    @Query(value = "update order_record o set o.status = ?2 where o.id = ?1"
    , nativeQuery = true)
    void modifyOrderRecordWithStatus(long id, int status);

}

修复了OrderRecordRepository中raw sql语句中的字段错误