Spring Hibernate

Shoaib1237
Member
Inscription: 04 April 2017

Spring Hibernate

Post By Shoaib1237 » 04 April 2017, 20:46

Hello . is there any one who can help . i nee to convert this piece of code into hibernate . thanks.

int supId = 0;
            rs0 = stmt.executeQuery("SELECT SupplierId FROM VendorOrder WHERE OrderNo=" + orderNo);
            if (rs0.next()) {
                supId = rs0.getInt("SupplierId");
            } else {
                System.out.println("No SupplierId");
                System.exit(1);
            }
Robin_OP7
Member
Inscription: 05 April 2017

Re: Spring Hibernate

Post By Robin_OP7 » 05 April 2017, 21:59

supId = (int)sessionFactory.getCurrentSession().
createQuery("SELECT SupplierId FROM VendorOrder WHERE OrderNo=?").setParameter(0, orderNo).uniqueResult();