1 /** 2 * Copyright 2011 The Kuali Foundation Licensed under the 3 * Educational Community License, Version 2.0 (the "License"); you may 4 * not use this file except in compliance with the License. You may 5 * obtain a copy of the License at 6 * 7 * http://www.osedu.org/licenses/ECL-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, 10 * software distributed under the License is distributed on an "AS IS" 11 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 * or implied. See the License for the specific language governing 13 * permissions and limitations under the License. 14 */ 15 16 package org.kuali.mobility.feedback.dao; 17 18 import javax.persistence.EntityManager; 19 import javax.persistence.PersistenceContext; 20 21 import org.kuali.mobility.feedback.entity.Feedback; 22 import org.springframework.stereotype.Repository; 23 24 @Repository 25 public class FeedbackDaoImpl implements FeedbackDao { 26 27 @PersistenceContext 28 private EntityManager entityManager; 29 30 public FeedbackDaoImpl() {} 31 32 public void saveFeedback(Feedback feedback) { 33 if (feedback == null) { 34 return; 35 } 36 if (feedback.getFeedbackId() == null) { 37 entityManager.persist(feedback); 38 } else { 39 entityManager.merge(feedback); 40 } 41 } 42 43 // public void deleteFeedbackById(Long id) { 44 // Query query = entityManager.createQuery("delete from Feedback f where feedbackId = :id"); 45 // query.setParameter("id", id); 46 // query.executeUpdate(); 47 // } 48 // 49 // public Feedback findFeedbackById(Long id) { 50 // Query query = entityManager.createQuery("select f from Feedback f where feedbackId = :id"); 51 // query.setParameter("id", id); 52 // return (Feedback) query.getSingleResult(); 53 // } 54 // 55 // @SuppressWarnings("unchecked") 56 // public List<Feedback> findAllFeedback() { 57 // Query query = entityManager.createQuery("select f from Feedback f order by f.feedbackId"); 58 // return query.getResultList(); 59 // } 60 // 61 // @SuppressWarnings("unchecked") 62 // public List<Feedback> findAllFeedbackByService(String service) { 63 // Query query = entityManager.createQuery("select f from Feedback f where service = :service order by f.feedbackId"); 64 // query.setParameter("service", service); 65 // return query.getResultList(); 66 // } 67 68 public EntityManager getEntityManager() { 69 return entityManager; 70 } 71 72 public void setEntityManager(EntityManager entityManager) { 73 this.entityManager = entityManager; 74 } 75 }