christianPa / full-hibernate-plugin-for-struts2

Automatically exported from code.google.com/p/full-hibernate-plugin-for-struts2
0 stars 0 forks source link

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

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
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.

Original issue reported on code.google.com by sudarsha...@gmail.com on 1 Mar 2013 at 2:53