FieldResult (Java EE 5)

Java EE API


javax.persistence Annotation Type FieldResult


@Target(value={})
@Retention(value=RUNTIME)
public @interface FieldResult

Implements: Annotation
@Target(value={})
@Retention(value=RUNTIME)

此类用于将查询的 SELECT 列表中指定的列映射到实体类的属性或字段。
示例:
   Query q = em.createNativeQuery(
       "SELECT o.id AS order_id, " +
           "o.quantity AS order_quantity, " +
           "o.item AS order_item, " +
         "FROM Order o, Item i " +
         "WHERE (order_quantity > 25) AND (order_item = i.id)",
       "OrderResults");

   @SqlResultSetMapping(name="OrderResults",
       entities={
           @EntityResult(entityClass=com.acme.Order.class, fields={
               @FieldResult(name="id", column="order_id"),
               @FieldResult(name="quantity", column="order_quantity"),
               @FieldResult(name="item", column="order_item")})
       })
 
英文文档:

Is used to map the columns specified in the SELECT list of the query to the properties or fields of the entity class.

 Example:
   Query q = em.createNativeQuery(
       "SELECT o.id AS order_id, " +
           "o.quantity AS order_quantity, " +
           "o.item AS order_item, " +
         "FROM Order o, Item i " +
         "WHERE (order_quantity > 25) AND (order_item = i.id)",
       "OrderResults");

   @SqlResultSetMapping(name="OrderResults",
       entities={
           @EntityResult(entityClass=com.acme.Order.class, fields={
               @FieldResult(name="id", column="order_id"),
               @FieldResult(name="quantity", column="order_quantity"),
               @FieldResult(name="item", column="order_item")})
       })
 

Since:
Java Persistence 1.0

Required Element Summary
 String
 String
 

Element Detail

abstract public String name()
类的持久字段或属性的名称。
英文文档:

name

public abstract String name
Name of the persistent field or property of the class.


abstract public String column()
SELECT 子句中的列的名称,即列别名(如果适用)。
英文文档:

column

public abstract String column
Name of the column in the SELECT clause - i.e., column aliases, if applicable.



Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!