BusinessRepository.java 1.2 KB
package com.bsth.repository;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.bsth.entity.Business;

import java.util.Date;
import java.util.List;

/**
 * 
 * @Interface: BusinessRepository(公司Repository数据持久层接口)
 * 
 * @Extends : BaseRepository
 * 
 * @Description: TODO(公司Repository数据持久层接口)
 * 
 * @Author bsth@lq
 * 
 * @Date 2016-05-03 9:21:17
 *
 * @Version 公交调度系统BS版 0.1
 * 
 */

@Repository
public interface BusinessRepository extends BaseRepository<Business, Integer> {

    List<Business> findByBusinessCode(String code);

    List<Business> findByUpCodeAndBusinessCode(String c1, String c2);
    
    @Query(value = "SELECT IFNULL(num,0) as maxId from (SELECT MAX(id) as num FROM bsth_c_business) k" , nativeQuery=true)
	long getMaxId();

    @Modifying
    @Query(value = "UPDATE Business b set b.businessName=?1 , b.upCode=?2, b.updateDate=?3 "
            + "where b.businessCode=?4")
    int update(String businessName, String upCode, Date updateDate,
               String businessCode);

}