SectionRepository.java 1.88 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 org.springframework.transaction.annotation.Transactional;

import com.bsth.entity.Section;

/**
 * 
 * @Interface: SectionRepository(路段Repository数据持久层接口)
 * 
 * @Extends : BaseRepository
 * 
 * @Description: TODO(路段Repository数据持久层接口)
 * 
 * @Author bsth@lq
 * 
 * @Date 2016年05月03日 上午9:21:17
 *
 * @Version 公交调度系统BS版 0.1
 * 
 */

@Repository
public interface SectionRepository extends BaseRepository<Section, Integer> {
	
	// 查询最大ID
	@Query(value = "SELECT IFNULL(num,0) as maxId from (SELECT MAX(id) as num FROM bsth_c_section) k"
			, nativeQuery=true)
	public int sectionMaxId();
	
	@Transactional
    @Modifying
	@Query(value="INSERT INTO bsth_c_section "+
    
				 "(section_code , section_name , croses_road , end_node, start_node ,"+
				 
				 "middle_node , gsection_vector, bsection_vector , section_type , csection_vector,"+
				 
				 "road_coding , section_distance , section_time , db_type, speed_limit ,"+
				 
				 "descriptions , versions) "+
    
			"VALUES (?1 , ?2 , ?3 , ?4 , ?5 , "+
					
					"?6 , GEOMFROMTEXT(?7) , GEOMFROMTEXT(?8) , ?9 , ?10 ,"+
					
					"?11 , ?12 , ?13 , ?14 , ?15 ,"+
					
					"?16 , ?17 "+
			")", nativeQuery=true)
	public void systemSave(String sectionCode , String sectionName , String crosesRoad , String endNode , String startNode,
			
						   String middleNode,String gsectionVector,String bsectionVector, String sectionType,String csectionVector,
						   
						   String roadCoding,double sectionDistance,double sectionTime,String dbType,double speedLimit,
						   
						   String descriptions, int versions);
	
	
	
}