1 //----------------------------------------------------------------------
2 //
3 // PerfectJPattern: "Design patterns are good but components are better!"
4 // QueryParameters.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.lang.annotation.*;
24
25 /**
26 * Defines the order and correspondence between interface method arguments and
27 * named query parameters. Named query parameters when retrieved they don't have
28 * a predictable order, besides compiled byte code loses the argument names
29 * thus without this annotation there would be no predictable way to map the
30 * finder method arguments to the query parameters.
31 * <br/><br/>
32 * For example a named query defined like:
33 * <pre><code>
34 * <query name="Customer.findByNumberOfOrdersBetween">
35 * <![CDATA[SELECT c1
36 * FROM Customer c1
37 * WHERE c1.id IN
38 * (SELECT c2.id
39 * FROM Customer c2 inner join c2.orders o
40 * WHERE o.date BETWEEN :Begin AND :End
41 * GROUP BY c2.id
42 * HAVING Count(*) >= :Minimum
43 * )
44 * ]]>
45 * </query>
46 * </code></pre>
47 * Would correspond to an interface method definition with
48 * the {@link QueryParameters} in the following way:
49 * <pre><code>
50 * public interface ICustomerDao
51 * extends IGenericDao<Long, Customer>
52 * {
53 * @QueryParameters(names = { "Begin", "End", "Minimum" })
54 * public List<Customer>
55 * findByNumberOfOrdersBetween(Date aBegin, Date anEnd, long aMinimum);
56 * }
57 * </pre></code>
58 * <br/>
59 *
60 * @author <a href="mailto:bravegag@hotmail.com">Giovanni Azua</a>
61 * @version $Revision: 1.0 $Date: Feb 12, 2009 11:08:00 PM $
62 */
63 @Retention(value = RetentionPolicy.RUNTIME)
64 public
65 @interface QueryParameters
66 {
67 //------------------------------------------------------------------------
68 // public
69 //------------------------------------------------------------------------
70 public String[]
71 names();
72 }