1 /*** $Id: FindEmployeeByPK.java,v 1.1.1.1 2004/05/18 10:50:21 mochoa Exp $ */
2
3 package cmd_dao.sample.common.hibernate.employee;
4 //dao
5 import org.j2ee.dao.AbstractHibernateDAOAction;
6 //dto
7 import cmd_dao.sample.common.dto.EmployeeTO;
8
9 /***
10 * Last modified $Date: 2004/05/18 10:50:21 $
11 * @version $Revision: 1.1.1.1 $
12 * @author Hibernate Action Generator
13 * This class is concrete implementation for an action using Hibernate.
14 *
15 * Based on an example of book Code Notes for J2EE, Edited by GREGORY BRILL,
16 * e-ISBN 0-679-64727-9
17 * Automated generated code, DO NOT EDIT
18 */
19 public class FindEmployeeByPK extends AbstractHibernateDAOAction {
20
21 private EmployeeTO employeeTO = null;
22
23 /***
24 * Default constructor, calls to the super class given the kind
25 * of action to be implement.
26 */
27 public FindEmployeeByPK() {
28 super(AbstractHibernateDAOAction.HQL_QUERY);
29 }
30
31
32 /***
33 * Class constructor setting the DTO.
34 * First calls to the default contructor to set the operation
35 * then set the private instance with the given DTO.
36 * @param dto for this action
37 */
38 public FindEmployeeByPK(EmployeeTO dto) {
39 this();
40 this.employeeTO = dto;
41 }
42
43
44 /***
45 * getter method for the private attribute
46 */
47 public EmployeeTO getEmployeeTO() {
48 return this.employeeTO;
49 }
50
51 /***
52 * getter method for the private attribute
53 */
54 public Object getTO() {
55 return this.employeeTO;
56 }
57
58 /***
59 * setter method for the private attribute
60 */
61 public void setEmployeeTO(EmployeeTO dto) {
62 this.employeeTO = dto;
63 }
64
65 /***
66 * setter method for the private attribute
67 */
68 public void setTO(Object dto) {
69 this.employeeTO = (EmployeeTO)dto;
70 }
71
72
73 /***
74 * private attribute to know if the query found the object
75 */
76 private boolean found = false;
77
78 /***
79 * static query string using HQL sintax, do not require dynamic computation
80 * to know the HQL syntax for finding the object throw his primary key
81 */
82 private static final String sql_stmt="from cmd_dao.sample.common.dto.EmployeeTO as EmployeeTO where EmployeeTO.no=:id";
83
84 /***
85 * Public constructor given the object primary.
86 * Automatically create an empty TO and set his primary key.
87 */
88 public FindEmployeeByPK(java.lang.Integer key) {
89 this();
90 employeeTO= new EmployeeTO();
91 employeeTO.setNo(key);
92 }
93
94 /***
95 * setter method for the private attribute
96 */
97 public void setNo(java.lang.Integer key) {
98 if (employeeTO==null)
99 employeeTO= new EmployeeTO();
100 employeeTO.setNo(key);
101 }
102
103
104 /***
105 * Return true if the object was found.
106 * otherwise false
107 */
108 public boolean isFound() {
109 return this.found;
110 }
111
112
113 /***
114 * Return the HQL query string used by Hibernate to find the
115 * object by his primary key.
116 */
117 public String getHQL() {
118 return this.sql_stmt;
119 }
120
121
122 /***
123 * After the execution of the HQL query by the action processor
124 * this method is called to transfer the result set (List) to the
125 * action.
126 */
127 public void handleResults(java.util.List rs) {
128 if (employeeTO==null) employeeTO = new EmployeeTO();
129 found = false;
130 if (!rs.isEmpty()) {
131 employeeTO = (EmployeeTO)rs.get(0);
132 found = true;
133 }
134 }
135
136 /***
137 * Return the names of the parameters used into the HQL query
138 */
139 public String[] getNamesForParams() {
140 return new String[] { "id" };
141 }
142
143 /***
144 * This method is called from DAOHibernateActionProcessorImpl
145 * They must return the parameters for the operation to be called.
146 * For insert/delete/update operations it only needs the transfer object
147 * For Load operation it needs the transfer object and primary key.
148 * @return an array of objects.
149 */
150 public Object[] getParameters() {
151 return new Object[] { this.employeeTO.getNo() };
152 }
153
154 }
155
156
This page was automatically generated by Maven