KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > test > annotations > query > Mark


1 //$Id: Mark.java,v 1.2 2005/06/10 18:13:00 epbernard Exp $
2
package org.hibernate.test.annotations.query;
3
4 import javax.persistence.AccessType;
5 import javax.persistence.ColumnResult;
6 import javax.persistence.Entity;
7 import javax.persistence.GeneratorType;
8 import javax.persistence.Id;
9 import javax.persistence.NamedNativeQuery;
10 import javax.persistence.SqlResultSetMapping;
11
12 /**
13  * Example of scalar result (not working right now)
14  * @author Emmanuel Bernard
15  */

16 @Entity(access=AccessType.FIELD)
17 @NamedNativeQuery(name="average", queryString="select avg(m.value) from Mark m", resultSetMapping="columnmapping")
18 @SqlResultSetMapping(
19     name="columnmapping",
20     columns = @ColumnResult(name="aver")
21 )
22 public class Mark {
23     @Id(generate=GeneratorType.AUTO)
24     public int id;
25     public int value;
26 }
27
Popular Tags