Struts2.2.1 and hibernate integration application
Posted on: March 4, 2011 at 12:00 AM
In this application, you will see how to integrate struts2.2.1 and hibernate.

Struts2.2.1 and hibernate integration application


The action class is called by the getModel() method of action class. This class is model class which has the getter setter method of form value and also map table column to property for accessing value of table column.


package net.roseindia.Model;


import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

@Table(name = "userinfo")
public class AddInformation implements Serializable {
private String firstname;
private String lastname;
private String age;
private String address;
private String gender;
private int id;

@Column(name = "id")
public int getId() {
return id;

@Column(name = "firstname")
public String getFirstname() {
return firstname;

@Column(name = "lastname")
public String getLastname() {
return lastname;

@Column(name = "age")
public String getAge() {
return age;

@Column(name = "address")
public String getAddress() {
return address;

@Column(name = "gender")
public String getGender() {
return gender;

public void setFirstname(String firstname) {
this.firstname = firstname;

public void setId(int id) { = id;

public void setLastname(String lastname) {
this.lastname = lastname;

public void setAge(String age) {
this.age = age;

public void setAddress(String address) {
this.address = address;

public void setGender(String gender) {
this.gender = gender;


Related Tags for Struts2.2.1 and hibernate integration application: