开发者

hibernate program

开发者 https://www.devze.com 2023-03-03 17:29 出处:网络
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);

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

精彩评论

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