001: package com.mockrunner.example.ejb;
002:
003: import java.util.Date;
004:
005: import javax.ejb.CreateException;
006: import javax.ejb.EJBException;
007: import javax.ejb.EntityBean;
008: import javax.ejb.EntityContext;
009: import javax.ejb.RemoveException;
010:
011: /*
012: * @ejb:bean name="BillEntity"
013: * display-name="BillEntity"
014: * type="CMP"
015: * cmp-version="2.x"
016: * primkey-field="id"
017: * jndi-name="com/mockrunner/example/UserEntity"
018: *
019: * @ejb:pk class="java.lang.Integer"
020: *
021: * @ejb:transaction type="Required"
022: *
023: * @ejb:finder signature="java.util.Collection findUnpaid()"
024: * query="SELECT OBJECT(t) FROM BillEntity as t WHERE t.paid = false"
025: *
026: * @ejb:finder signature="java.util.Collection findAll()"
027: *
028: * @jboss:persistence datasource="java:/MySQLDB"
029: * table-name="BillEntity"
030: * create-table="true"
031: * remove-table="false"
032: **/
033: /**
034: * This CMP entity bean represents a bill.
035: * It has a date, and a marker if it is paid.
036: * It has two custom finders, namely
037: * <code>findUnpaid()</code> and <code>findAll()</code>.
038: */
039: public abstract class BillEntityBean implements EntityBean {
040: public EntityContext entityContext;
041:
042: /*
043: * @ejb:interface-method
044: * @ejb:persistence
045: * @ejb:pk-field
046: * @jboss:column-name name="id"
047: **/
048: public abstract Integer getId();
049:
050: public abstract void setId(Integer id);
051:
052: /*
053: * @ejb:interface-method
054: * @ejb:persistence
055: * @jboss:column-name name="date" sql-type="DATETIME" jdbc-type="DATE"
056: **/
057: public abstract Date getDate();
058:
059: /*
060: * @ejb:interface-method
061: **/
062: public abstract void setDate(Date date);
063:
064: /*
065: * @ejb:interface-method
066: * @ejb:persistence
067: * @jboss:column-name name="paid"
068: **/
069: public abstract boolean getPaid();
070:
071: /*
072: * @ejb:interface-method
073: **/
074: public abstract void setPaid(boolean isPaid);
075:
076: /*
077: * @ejb:create-method
078: **/
079: public Integer ejbCreate(Integer id) throws EJBException,
080: CreateException {
081: setId(id);
082: return null;
083: }
084:
085: public void ejbPostCreate(Integer id) {
086: }
087:
088: public void setEntityContext(EntityContext context) {
089: entityContext = context;
090: }
091:
092: public void unsetEntityContext() {
093: entityContext = null;
094: }
095:
096: public void ejbActivate() {
097: }
098:
099: public void ejbPassivate() {
100: }
101:
102: public void ejbLoad() {
103: }
104:
105: public void ejbStore() {
106: }
107:
108: public void ejbRemove() throws RemoveException {
109: }
110: }
|