package com.jasamedika.medifirst2000.dao;

import java.util.List;

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.RuanganM;

/**
 * Repository class for Kelas
 * 
 * @author Roberto
 */
@Repository("RuanganMDao")
public interface RuanganMDao extends
		PagingAndSortingRepository<RuanganM, Integer> {

	// native query example, misal ada 2 parameter yaitu param2 dan param2
	@Query(value = "select namaRuangan from ruangan_M where kdRuangan in (select nilaiField from settingDataFixed_M) and (id =:param1 or id = :param2 ) "
			+ "union all "
			+ "select namaDepartemen as namaRuangan from departemen_M  where char_length(namaDepartemen) = 12 "
			+ "union all", nativeQuery = true)
	List<Object[]> getNativeNamaRuangan(@Param("param1") String param1,
			@Param("param2") String param2);

	// native query example
	@Query(value = "select namakelas as namaRuangan from kelas_M where strpos(namaKelas,'N')=1", nativeQuery = true)
	List<Object[]> getNativeNamaKelas();

}
