1 25 package org.objectweb.easybeans.tests.common.ejbs.entity.simpleentity; 26 27 import java.io.Serializable ; 28 29 import javax.persistence.Entity; 30 import javax.persistence.EntityResult; 31 import javax.persistence.FieldResult; 32 import javax.persistence.Id; 33 import javax.persistence.NamedNativeQuery; 34 import javax.persistence.NamedQueries; 35 import javax.persistence.NamedQuery; 36 import javax.persistence.SqlResultSetMapping; 37 import javax.persistence.SqlResultSetMappings; 38 import javax.persistence.Table; 39 40 45 @Entity 46 @Table(name = "SIMPLE") 47 @NamedQueries({@NamedQuery(name = "findByName", query = "SELECT e FROM SimpleEntity e WHERE e.name = :entityName "), 48 @NamedQuery(name = "findByIdNamed", query = "SELECT e FROM SimpleEntity e WHERE e.id > :entityId")}) 49 @SqlResultSetMappings({ 50 @SqlResultSetMapping(name = "SimpleEntityResult", entities = @EntityResult(entityClass = SimpleEntity.class)), 51 @SqlResultSetMapping(name = "MappedSimpleEntity", entities = @EntityResult(entityClass = SimpleEntity.class, fields = { 52 @FieldResult(name = "id", column = "entity_id"), @FieldResult(name = "name", column = "entity_name")}))}) 53 @NamedNativeQuery(name = "findByAll", query = "SELECT e.id, e.name FROM SIMPLE e ORDER BY e.id", 54 resultSetMapping = "SimpleEntityResult") 55 public class SimpleEntity implements Serializable { 56 57 60 private static final long serialVersionUID = 7281003617281981005L; 61 62 65 private int id; 66 67 70 private String name; 71 72 76 @Id 77 public int getId() { 78 return id; 79 } 80 81 85 public void setId(final int id) { 86 this.id = id; 87 } 88 89 93 public void setName(final String name) { 94 this.name = name; 95 } 96 97 101 public String getName() { 102 return name; 103 } 104 105 109 @Override 110 public String toString() { 111 StringBuilder sb = new StringBuilder (); 112 sb.append("SimpleEntity[id=").append(id).append(", name=").append(getName()).append("]"); 113 return sb.toString(); 114 } 115 116 } 117 | Popular Tags |