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.Retention;
013import java.lang.annotation.Target;
014
015import static java.lang.annotation.RetentionPolicy.RUNTIME;
016
017/**
018 * Is used to map the columns specified in the SELECT list
019 * of the query to the properties or fields of the entity class.
020 * <p>
021 * <pre>
022 *
023 * Example:
024 *   Query q = em.createNativeQuery(
025 *       "SELECT o.id AS order_id, " +
026 *           "o.quantity AS order_quantity, " +
027 *           "o.item AS order_item, " +
028 *         "FROM Order o, Item i " +
029 *         "WHERE (order_quantity &gt; 25) AND (order_item = i.id)",
030 *       "OrderResults");
031 *
032 *   &#064;SqlResultSetMapping(name="OrderResults",
033 *       entities={
034 *           &#064;EntityResult(entityClass=com.acme.Order.class, fields={
035 *               &#064;FieldResult(name="id", column="order_id"),
036 *               &#064;FieldResult(name="quantity", column="order_quantity"),
037 *               &#064;FieldResult(name="item", column="order_item")})
038 *       })
039 * </pre>
040 *
041 * @since Java Persistence 1.0
042 */
043@Target({})
044@Retention(RUNTIME)
045
046public @interface FieldResult {
047
048  /**
049   * Name of the persistent field or property of the class.
050   *
051   * @return name
052   */
053  String name();
054
055  /**
056   * Name of the column in the SELECT clause - i.e., column
057   * aliases, if applicable.
058   *
059   * @return column
060   */
061  String column();
062}