001/** 002 * Copyright 2005-2016 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 */ 016package org.kuali.rice.krad.dao.impl; 017 018import javax.persistence.EntityManager; 019import javax.persistence.PersistenceContext; 020 021import org.kuali.rice.core.framework.persistence.jpa.criteria.Criteria; 022import org.kuali.rice.core.framework.persistence.jpa.criteria.QueryByCriteria; 023import org.kuali.rice.krad.bo.DocumentHeader; 024import org.kuali.rice.krad.dao.DocumentHeaderDao; 025 026/** 027 * This class is the JPA implementation of the DocumentHeaderDao interface. 028 */ 029public class DocumentHeaderDaoJpa implements DocumentHeaderDao { 030 031 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DocumentHeaderDaoJpa.class); 032 033 @PersistenceContext 034 private EntityManager entityManager; 035 036 /** 037 * @see org.kuali.rice.krad.dao.DocumentHeaderDao#getDocumentHeaderBaseClass() 038 */ 039 public Class getDocumentHeaderBaseClass() { 040 LOG.debug("Method getDocumentHeaderBaseClass() returning class " + DocumentHeader.class.getName()); 041 return DocumentHeader.class; 042 } 043 044 /** 045 * @see org.kuali.dao.DocumentHeaderDao#getByDocumentHeaderId(java.lang.Long) 046 */ 047 public DocumentHeader getByDocumentHeaderId(String id) { 048 Criteria criteria = new Criteria(DocumentHeader.class.getName()); 049 criteria.eq("FDOC_NBR", id); 050 return (DocumentHeader) new QueryByCriteria(entityManager, criteria).toQuery().getSingleResult(); 051 } 052 053 /** 054 * @return the entityManager 055 */ 056 public EntityManager getEntityManager() { 057 return this.entityManager; 058 } 059 060 /** 061 * @param entityManager the entityManager to set 062 */ 063 public void setEntityManager(EntityManager entityManager) { 064 this.entityManager = entityManager; 065 } 066 067}