You are on page 1of 1

public String generateId(String idName, Session session) {

Session newSession = null;


try {
newSession = GeneratorSession;
BigDecimal nextId;
Connection con = newSession.connection();
con.setAutoCommit(false);
CallableStatement cstmt = con.prepareCall("{ call GENERATE_NEXT_ID(?
, ?) }");
cstmt.setString(1, idName);
cstmt.registerOutParameter(2, java.sql.Types.NUMERIC);
cstmt.execute();
nextId = (BigDecimal) cstmt.getObject(2);
cstmt.close();
con.commit();
return nextId.toString();
} catch (SQLException e) {
try {
session.connection().rollback();
} catch (HibernateException he) {
throw new HibernateRuntimeException("SQL error", e);
} catch (SQLException sqlE) {
throw new HibernateRuntimeException("SQL error", e);
}
} catch (org.hibernate.HibernateException e) {
}
finally {
if(newSession != null) {
newSession.clear();
newSession.close();
}
}
}

DELIMITER //
CREATE PROCEDURE getInvoiceList(IN delind INT )
BEGIN
SELECT cst.cst_name,sinv.sinv_id,sinv.create_dt,sinv.closed_dt
FROM sinv_header sinv LEFT JOIN cust_header cst ON cst.cst_id = sinv.cst_id
WHERE sinv.del_ind = delind;
END //
DELIMITER ;

You might also like