Export to GitHub

full-hibernate-plugin-for-struts2 - issue #41

java.lang.NullPointerException insert new record into database using hibernate3 & struts2


Posted on Mar 1, 2013 by Massive Camel

What steps will reproduce the problem? 1. import java.util.List;

import org.hibernate.Session; import org.hibernate.Transaction;

import com.ami.bean.Tender; import com.googlecode.s2hibernate.struts2.plugin.annotations.SessionTarget; import com.googlecode.s2hibernate.struts2.plugin.annotations.TransactionTarget;

public class TenderDAOImpl implements TenderDAO{ @SessionTarget Session session=null;

@TransactionTarget
Transaction transaction=null;


/**
 * Used to save or update a user.
 */
@Override
public void saveUpdateTender(Tender tender) {
    try {
        /*System.out.println(t.getId()+t.getAttachment()+"getCdate"+t.getCdate()+"getEdate"+t.getEdate()+"getEmd()"+t.getEmd()+"getOdate()"+t.getOdate()+"getOrgname()"+t.getOrgname()+"getPredate()"+t.getPredate()+"getSdate()"+t.getSdate()+"getState()"+t.getState()+"getStatus"+t.getStatus()+"getTno"+t.getTno()+"getTrem"+t.getTrem()+"getTval"+t.getTval()+"getWdesc"+t.getWdesc()+"getTid"+t.getTid());*/
        System.out.println("sdhj");
        session.saveOrUpdate(tender);
    } catch (Exception e) {
        transaction.rollback();
        e.printStackTrace();
    }
}

} 2. 3.

What is the expected output? What do you see instead? insert record into database but null pointer exception occured at transaction.rollback(); line in above code

What version of the product are you using? On what operating system? struts2.1.6,hibernate 3 and mysql-connector-java5.0.5 and window 7 homebasic 64bit

Please provide any additional information below.

Status: New

Labels:
Type-Defect Priority-Medium