001 package biz.wedoit4u.ejb.entity;
002
003 import java.sql.SQLException;
004 import java.util.Set;
005 import javax.ejb.CreateException;
006 import javax.ejb.FinderException;
007 import javax.naming.NamingException;
008 import biz.wedoit4u.databeans.DatabaseHelper;
009
010 /**
011 * The implementation of the entity bean that represents a record in the
012 * <code>customer_types</code> table.
013 *
014 * <p>Copyright 2003, Rakesh Vidyadharan</p>
015 *
016 * @author Rakesh Vidyadharan on 16<sup><small>th</small></sup> September 2003
017 * @version $Id: CustomerTypeBean.java,v 1.6 2004/05/26 11:42:34 rakesh Exp $
018 */
019 public abstract class CustomerTypeBean extends EntityBeanAdapter
020 {
021 /**
022 * Create a new <code>customer_types</code> record with just the
023 * value for the required column. This method obtains the next
024 * <code>sequence</code> value for the <code>customer_type_id</code>
025 * value, and sets the <code>customer_type_id</code> value to the
026 * <code>sequence value</code>.
027 *
028 * @see DatabaseHelper#getNextSequenceValue( String )
029 * @param type - The <code>type</code> value.
030 * @return Integer - The primary key value of the entity bean
031 * representing the new record.
032 * @throws CreateException - If errors are encountered while creating
033 * the new record.
034 */
035 public Integer ejbCreate( String type ) throws CreateException
036 {
037 try
038 {
039 setCustomerTypeId( DatabaseHelper.getNextSequenceValue( "sequence_customer_type_id" ) );
040 }
041 catch ( NamingException nex )
042 {
043 CreateException cex = new CreateException( nex.toString() );
044 cex.setStackTrace( nex.getStackTrace() );
045 throw cex;
046 }
047 catch ( SQLException sex )
048 {
049 CreateException cex = new CreateException( sex.toString() );
050 cex.setStackTrace( sex.getStackTrace() );
051 throw cex;
052 }
053 setType( type );
054
055 return null;
056 }
057
058 /**
059 * Mandatory matching <code>postCreate</code> method to the
060 * {@link #ejbCreate( String )} method. No special handling required
061 * after the new record is created.
062 *
063 * @param type - The <code>type</code> value.
064 */
065 public void ejbPostCreate( String type ) {}
066
067 /**
068 * Create a new <code>customer_types</code> record. This method
069 * obtains the next <code>sequence</code> value for the
070 * <code>customer_id</code> value, and sets the <code>
071 * customer_type_id</code> value to the <code>sequence value</code>.
072 *
073 * @see biz.wedoit4u.databeans.DatabaseHelper#getNextSequenceValue( String )
074 * @param type - The <code>type</code> value.
075 * @param description - The <code>description</code> value.
076 * @return Integer - The primary key value of the entity bean
077 * representing the new record.
078 * @throws CreateException - If errors are encountered while creating
079 * the new record.
080 */
081 public Integer ejbCreate( String type, String description )
082 throws CreateException
083 {
084 try
085 {
086 setCustomerTypeId( DatabaseHelper.getNextSequenceValue( "sequence_customer_type_id" ) );
087 }
088 catch ( NamingException nex )
089 {
090 CreateException cex = new CreateException( nex.toString() );
091 cex.setStackTrace( nex.getStackTrace() );
092 throw cex;
093 }
094 catch ( SQLException sex )
095 {
096 CreateException cex = new CreateException( sex.toString() );
097 cex.setStackTrace( sex.getStackTrace() );
098 throw cex;
099 }
100 setType( type );
101 setDescription( description );
102
103 return null;
104 }
105
106 /**
107 * Mandatory matching <code>postCreate</code> method to the
108 * {@link #ejbCreate( String, String )} method. No special handling
109 * required after the new record is created.
110 *
111 * @param type - The <code>type</code> value.
112 * @param description - The <code>description</code> value.
113 */
114 public void ejbPostCreate( String type, String description ) {}
115
116 /**
117 * Return the value in the <code>customer_type_id</code> column.
118 *
119 * @return int - The value in the column.
120 */
121 public abstract int getCustomerTypeId();
122
123 /**
124 * Set the value in the <code>customer_type_id</code> column.
125 *
126 * @param customer_typeId - The value to set.
127 */
128 public abstract void setCustomerTypeId( int customer_typeId );
129
130 /**
131 * Return the value in the <code>type</code> column.
132 *
133 * @return String - The value in the column.
134 */
135 public abstract String getType();
136
137 /**
138 * Set the value in the <code>type</code> column.
139 *
140 * @param type - The value to set.
141 */
142 public abstract void setType( String type );
143
144 /**
145 * Return the value in the <code>description</code> column.
146 *
147 * @return String - The value in the column.
148 */
149 public abstract String getDescription();
150
151 /**
152 * Set the value in the <code>description</code> column.
153 *
154 * @param description - The value to set.
155 */
156 public abstract void setDescription( String description );
157
158 /**
159 * Return a <code>Set</code> of references to the {@link Customer}
160 * entity beans that belong to this <code>customer_type</code>.
161 *
162 * @return Set - The <code>Set</code> of customers belonging to this
163 * type.
164 */
165 public abstract Set getCustomers();
166
167 /**
168 * Set a <code>Set</code> of references to the {@link Customer}
169 * entity beans that belong to this <code>customer_type</code>.
170 *
171 * @param customers - The <code>Set</code> of customers belonging to
172 * this type.
173 */
174 public abstract void setCustomers( Set customers );
175 }