001/* 002 * Copyright (c) 2008, 2009, 2011 Oracle, Inc. All rights reserved. 003 * 004 * This program and the accompanying materials are made available under the 005 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 006 * which accompanies this distribution. The Eclipse Public License is available 007 * at http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution License 008 * is available at http://www.eclipse.org/org/documents/edl-v10.php. 009 */ 010package javax.persistence; 011 012import java.lang.annotation.Repeatable; 013import java.lang.annotation.Retention; 014import java.lang.annotation.Target; 015 016import static java.lang.annotation.ElementType.TYPE; 017import static java.lang.annotation.RetentionPolicy.RUNTIME; 018 019/** 020 * Specifies a named native SQL query. Query names are scoped to the persistence unit. The 021 * <code>NamedNativeQuery</code> annotation can be applied to an entity or mapped superclass. 022 * 023 * @since Java Persistence 1.0 024 */ 025@Target({TYPE}) 026@Retention(RUNTIME) 027@Repeatable(NamedNativeQueries.class) 028public @interface NamedNativeQuery { 029 /** 030 * The name used to refer to the query with the {@link EntityManager} methods that create query objects. 031 * 032 * @return The name 033 */ 034 String name(); 035 036 /** 037 * The SQL query string. 038 * 039 * @return The SQL string 040 */ 041 String query(); 042 043 /** 044 * Query properties and hints. (May include vendor-specific query hints.) 045 * 046 * @return any hints 047 */ 048 QueryHint[] hints() default {}; 049 050 /** 051 * The class of the result. 052 * 053 * @return The result class 054 */ 055 Class resultClass() default void.class; 056 057 /** 058 * The name of a {@link SqlResultSetMapping}, as defined in metadata. 059 * 060 * @return ResultSet mapping 061 */ 062 String resultSetMapping() default ""; 063}