HP (Hewlett-Packard) 5991-5565 Network Card User Manual


 
<property name="firstName" type="java.lang.String">
<column name="FIRST_NAME" length="30" />
</property>
<property name="lastName" type="java.lang.String">
<column name="LAST_NAME" length="30" />
</property>
</class>
</hibernate-mapping>
8. Hibernate uses a Plain Old Java Object (POJO) to pass values between the application tier
and the persistent tier. Change your default directory to the following path:
# cd $CATALINA_HOME/webapps/SimpleDemo/WEB-INF/classes \
/com/hp/osms/hibernate
In this directory, create a Hibernate POJO file named
$CATALINA_HOME/webapps/SimpleDemo/WEB-INF \
/classes/com/hp/osms/hibernate/Users.java according to the mapping file for
your application. Add the following lines:
package com.hp.osms.hibernate;
public class Users implements java.io.Serializable {
private Long userId;
private String firstName;
private String lastName;
public Users() {
}
public Users(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
public Long getUserId() {
return this.userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public String getFirstName() {
return this.firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return this.lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
9. Compile a Hibernate POJO file and move the class file into
$CATALINA_HOME/webapps/SimpleDemo/WEB-INF \
/classes/com/hp/osms/hibernate/Users.java by entering the following command:
# javac Users.java
The preceding command creates a class file named:
$CATALINA_HOME/webapps/SimpleDemo/WEB-INF \
/classes/com/hp/osms/hibernate/Users.class
10. Test Hibernate functionality such as inserting, updating, deleting, and retrieving data from
the database, by creating a sample JSP file named
$CATALINA_HOME/webapps/SimpleDemo/hibernate.jsp.
The following code fragment from hibernate.jsp shows how to use Hibernate to insert
data into the database:
40