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


This is one of the most important class in the application. This class is usually guided by stuts.xml file. According to action the struts.xml file it calls the methods in the action class. This class used Dao class for accessing database.


package net.roseindia.action;

import java.util.List;

import net.roseindia.Model.AddInformation;
import net.roseindia.dao.InformationDAO;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class InformationAction extends ActionSupport implements ModelDriven {
private AddInformation obAddInfo;
private List infoList;
private int id1;

private InformationDAO obDao = new InformationDAO();

public String execute() throws Exception {
this.infoList = obDao.list1();
return SUCCESS;

public String add() {
if (obAddInfo.getFirstname().equals("")||obAddInfo.getLastname().equals("")||obAddInfo.getGender().equals("")||obAddInfo.getAge().equals("")||obAddInfo.getAddress().equals("")) {
addActionError("Please enter all valuees");
return ERROR;
return SUCCESS;

public String delete() {
System.out.println("Id : " + getId1());
System.out.println("Delete Success");
return SUCCESS;

public Object getModel() {
obAddInfo = new AddInformation();
return obAddInfo;

public int getId1() {
return id1;

public void setId1(int id1) {
this.id1 = id1;

public List getInfoList() {
return infoList;

public void setInfoList(List infoList) {
this.infoList = infoList;


Related Tags for Struts2.2.1 and hibernate integration application: