package com.jasamedika.medifirst2000.dao;

import java.util.List;
import java.util.Map;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.jasamedika.medifirst2000.entities.JenisWaktu;

@Repository("JenisWaktuDao")
public interface JenisWaktuDao extends PagingAndSortingRepository<JenisWaktu, Integer>, JpaSpecificationExecutor{
	
	@Query("select model from JenisWaktu model where model.kdJenisWaktu=:kdJenisWaktu")
	JenisWaktu findJenisWaktuBykd(@Param("kdJenisWaktu") Byte kdJenisWaktu);
	
	@Query("select new map(a.id as id, a.jenisWaktu as jenisWaktu) " +
			" from JenisWaktu a where a.statusEnabled in('true')")
	List<Map<String, Object>> getJenisWaktu();
	
	@Query("select max(a.id+1) from JenisWaktu a")
	public Integer getNo();
	
}
