1 //---------------------------------------------------------------------- 2 // 3 // PerfectJPattern: "Design patterns are good but components are better!" 4 // IQuery.java Copyright (c) 2009 Giovanni Azua Garcia 5 // bravegag@hotmail.com 6 // 7 // This program is free software; you can redistribute it and/or 8 // modify it under the terms of the GNU General Public License 9 // as published by the Free Software Foundation; either version 3 10 // of the License, or (at your option) any later version. 11 // 12 // This program is distributed in the hope that it will be useful, 13 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 // GNU General Public License for more details. 16 // 17 // You should have received a copy of the GNU General Public License 18 // along with this program; if not, see <http://www.gnu.org/licenses/>. 19 // 20 //---------------------------------------------------------------------- 21 package org.perfectjpattern.jee.api.integration.dao; 22 23 import java.util.*; 24 25 import org.perfectjpattern.core.api.structural.adapter.*; 26 27 /** 28 * Abstract definition of Query available for the DAO implementation. 29 * The DAO API exposes this interface but it will be automatically adapted 30 * from the underlying JPA-specific implementation (see {@link IAdapter}). 31 * <br/><br/> 32 * JPA and specific implementations define similar abstractions e.g. 33 * Query but despite their similarities, their types actually 34 * mismatch making it difficult to provide a generic unified DAO 35 * solution. 36 * <br/><br/> 37 * Note that this is a subset of the functionality that the underlying 38 * implementation offers. This is the subset required to make the DAO 39 * portable. 40 * 41 * @author <a href="mailto:bravegag@hotmail.com">Giovanni Azua</a> 42 * @version $Revision: 1.0 $Date: Feb 18, 2009 10:31:58 AM $ 43 */ 44 public 45 interface IQuery 46 { 47 //------------------------------------------------------------------------ 48 // public 49 //------------------------------------------------------------------------ 50 /** 51 * Returns the query results as a List 52 * 53 * @return query results as a List 54 */ 55 public <E> List<E> 56 getResultList(); 57 58 //------------------------------------------------------------------------ 59 /** 60 * Returns the query result as a single result 61 * 62 * @return query result as a single result 63 */ 64 public Object 65 getSingleResult(); 66 67 //------------------------------------------------------------------------ 68 /** 69 * Returns the number of entities updated or deleted. Executes an update 70 * or delete statement. 71 * 72 * @return number of entities updated or deleted 73 */ 74 public int 75 executeUpdate(); 76 }