package com.jasamedika.medifirst2000.dao.custom.impl;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.springframework.stereotype.Repository;

/**
 * Repository Custom class untuk Kalkulator Math Operation
 * Menggunakan select query ke DATABASE
 * 
 * @author Roberto
 */
@Repository("KalkulatorDaoCustom")
public class KalkulatorDaoCustomImpl {

	@PersistenceContext
	protected EntityManager em;

	public KalkulatorDaoCustomImpl() {
	}

	public Integer calculateFromString(String inputOperationMath) {
		Query query = em.createNativeQuery("SELECT " + inputOperationMath);
		return (Integer) query.getSingleResult();
	}

}
