1 package org.hibernate.test.annotations.query; 3 4 import javax.persistence.DiscriminatorColumn; 5 import javax.persistence.Entity; 6 import javax.persistence.EntityResult; 7 import javax.persistence.FieldResult; 8 import javax.persistence.Inheritance; 9 import javax.persistence.NamedNativeQuery; 10 import javax.persistence.SqlResultSetMapping; 11 import javax.persistence.Id; 12 import javax.persistence.GeneratorType; 13 14 17 @Entity 18 @DiscriminatorColumn(name = "disc") 19 @Inheritance(discriminatorValue = "Dic") 20 @SqlResultSetMapping( 21 name="dictionary", entities = { 22 @EntityResult( 23 name="org.hibernate.test.annotations.query.Dictionary", 24 fields = { 25 @FieldResult(name="id", column="id"), 26 @FieldResult(name="name", column="name"), 27 @FieldResult(name="editor", column="editor") 28 }, 29 discriminatorColumn = "type" 30 ) 31 } 32 ) 33 @NamedNativeQuery(name="all.dictionaries", 34 queryString="select id, name, editor, disc as type from Dictionary", 35 resultSetMapping="dictionary") 36 public class Dictionary { 37 private Integer id; 38 private String name; 39 private String editor; 40 41 @Id(generate=GeneratorType.AUTO) 42 public Integer getId() { 43 return id; 44 } 45 46 public void setId(Integer id) { 47 this.id = id; 48 } 49 50 public String getName() { 51 return name; 52 } 53 54 public void setName(String name) { 55 this.name = name; 56 } 57 58 public String getEditor() { 59 return editor; 60 } 61 62 public void setEditor(String editor) { 63 this.editor = editor; 64 } 65 } 66 | Popular Tags |