001: /**
002: * EasyBeans
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: easybeans@ow2.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: SimpleEntity.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.common.ejbs.entity.simpleentity;
025:
026: import java.io.Serializable;
027:
028: import javax.persistence.Entity;
029: import javax.persistence.EntityResult;
030: import javax.persistence.FieldResult;
031: import javax.persistence.Id;
032: import javax.persistence.NamedNativeQuery;
033: import javax.persistence.NamedQueries;
034: import javax.persistence.NamedQuery;
035: import javax.persistence.SqlResultSetMapping;
036: import javax.persistence.SqlResultSetMappings;
037: import javax.persistence.Table;
038:
039: /**
040: * Simple entity used in the EntityManager tests.
041: * @author Gisele Pinheiro Souza
042: * @author Eduardo Studzinski Estima de Castro
043: */
044: @Entity
045: @Table(name="SIMPLE")
046: @NamedQueries({@NamedQuery(name="findByName",query="SELECT e FROM SimpleEntity e WHERE e.name = :entityName "),@NamedQuery(name="findByIdNamed",query="SELECT e FROM SimpleEntity e WHERE e.id > :entityId")})
047: @SqlResultSetMappings({@SqlResultSetMapping(name="SimpleEntityResult",entities=@EntityResult(entityClass=SimpleEntity.class)),@SqlResultSetMapping(name="MappedSimpleEntity",entities=@EntityResult(entityClass=SimpleEntity.class,fields={@FieldResult(name="id",column="entity_id"),@FieldResult(name="name",column="entity_name")}))})
048: @NamedNativeQuery(name="findByAll",query="SELECT e.id, e.name FROM SIMPLE e ORDER BY e.id",resultSetMapping="SimpleEntityResult")
049: public class SimpleEntity implements Serializable {
050:
051: /**
052: * The serial version.
053: */
054: private static final long serialVersionUID = 7281003617281981005L;
055:
056: /**
057: * The bean Id.
058: */
059: private int id;
060:
061: /**
062: * The bean name.
063: */
064: private String name;
065:
066: /**
067: * Gets the bean Id.
068: * @return the id of the bean.
069: */
070: @Id
071: public int getId() {
072: return id;
073: }
074:
075: /**
076: * Sets bean Id.
077: * @param id the bean id.
078: */
079: public void setId(final int id) {
080: this .id = id;
081: }
082:
083: /**
084: * Sets the bean name.
085: * @param name bean name.
086: */
087: public void setName(final String name) {
088: this .name = name;
089: }
090:
091: /**
092: * Gets the bean name.
093: * @return bean name.
094: */
095: public String getName() {
096: return name;
097: }
098:
099: /**
100: * Computes a string representation of this bean.
101: * @return string representation.
102: */
103: @Override
104: public String toString() {
105: StringBuilder sb = new StringBuilder();
106: sb.append("SimpleEntity[id=").append(id).append(", name=")
107: .append(getName()).append("]");
108: return sb.toString();
109: }
110:
111: }
|