import org.hibernate.Session;
import org.hibernate.Transaction;
import com.Xz;
import com.HibernateSessionFactory;
import com.opensymphony.xwork2.ActionSupport;


public class SubmitXzAction extends ActionSupport {

	private Xz xz;

	public Xz getXz() {
		return xz;
	}

	public void setXz(Xz xz) {
		this.xz = xz;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		return SUCCESS;
	}
	
	public String submit() throws Exception{
		try{
			Session session=HibernateSessionFactory.getSession();
			Transaction tx=session.beginTransaction();
			session.save(xz);
			tx.commit();
			return SUCCESS;
		}catch(Exception e){
			e.printStackTrace();
			HibernateSessionFactory.getSession().close();
			return ERROR;
		}
	}
	
}
