1 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 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 |