1 /*
2  * Copyright (c) 2008, 2019 Oracle and/or its affiliates. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v. 2.0 which is available at
6  * http://www.eclipse.org/legal/epl-2.0,
7  * or the Eclipse Distribution License v. 1.0 which is available at
8  * http://www.eclipse.org/org/documents/edl-v10.php.
9  *
10  * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
11  */

12
13 // Contributors:
14 //     Petros Splinakis - 2.2
15 //     Linda DeMichiel - 2.1
16 //     Linda DeMichiel - 2.0
17
18 package javax.persistence;
19
20 import java.lang.annotation.Repeatable;
21 import java.lang.annotation.Target;
22 import java.lang.annotation.Retention;
23 import static java.lang.annotation.ElementType.TYPE;
24 import static java.lang.annotation.RetentionPolicy.RUNTIME;
25
26 /**
27  * Specifies a named native SQL query.
28  * Query names are scoped to the persistence unit.
29  * The <code>NamedNativeQuery</code> annotation can be applied to an 
30  * entity or mapped superclass.
31  *
32  * @since 1.0
33  */

34 @Repeatable(NamedNativeQueries.class)
35 @Target({TYPE}) 
36 @Retention(RUNTIME)
37 public @interface NamedNativeQuery { 
38
39     /**
40      * The name used to refer to the query with the {@link EntityManager} 
41      * methods that create query objects.
42      */

43     String name();
44
45     /** The SQL query string. */
46     String query();
47
48     /** Query properties and hints.  (May include vendor-specific query hints.) */
49     QueryHint[] hints() default {};
50
51     /** The class of the result. */
52     Class resultClass() default void.class
53
54     /** The name of a {@link SqlResultSetMapping}, as defined in metadata. */
55     String resultSetMapping() default "";
56 }
57