开发者

hibernate program

I wrote a program in netbeans on hibernate framework to persist my data in mysql db, Everything is going fine, the main is arising when I am using the snippet session.save(newcustomer);

session--object of Session. newcustomer-- object of entity class.

Sample Snippet--

public tab_customer create(tab_customer newCustomer) {
     Transaction transaction = session.beginTransaction();
        transaction.begin();
        System.out.println(transaction.isActive());

        session.save(newCustomer);

        transaction.commit();

        return newCustomer;
    }

Its throwing error can anyone help me pl开发者_高级运维ease.


It seems to me that you begin two transactions. Comment out transaction.begin();.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜