001 /** 002 * Copyright 2005-2013 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.rice.krad.dao.impl; 017 018 import javax.persistence.EntityManager; 019 import javax.persistence.PersistenceContext; 020 021 import org.apache.log4j.Logger; 022 import org.kuali.rice.core.framework.persistence.jpa.criteria.Criteria; 023 import org.kuali.rice.core.framework.persistence.jpa.criteria.QueryByCriteria; 024 import org.kuali.rice.krad.bo.Attachment; 025 import org.kuali.rice.krad.dao.AttachmentDao; 026 027 /** 028 * This class is the JPA implementation of the NoteDao interface. 029 * 030 * @author Kuali Rice Team (rice.collab@kuali.org) 031 */ 032 public class AttachmentDaoJpa implements AttachmentDao { 033 034 private static Logger LOG = Logger.getLogger(AttachmentDaoJpa.class); 035 036 @PersistenceContext 037 private EntityManager entityManager; 038 039 public Attachment getAttachmentByNoteId(Long noteId) { 040 Criteria criteria = new Criteria(Attachment.class.getName()); 041 criteria.eq("noteIdentifier", noteId); 042 return (Attachment) new QueryByCriteria(entityManager, criteria).toQuery().getSingleResult(); 043 } 044 045 /** 046 * @return the entityManager 047 */ 048 public EntityManager getEntityManager() { 049 return this.entityManager; 050 } 051 052 /** 053 * @param entityManager the entityManager to set 054 */ 055 public void setEntityManager(EntityManager entityManager) { 056 this.entityManager = entityManager; 057 } 058 059 }