I have the code below to execute SQL in a java method, im getting a null: java.lang.NullPointerException
when running the code.
public void addPrevious(TodaysDate Date){
String paymentDate = ("SELECT PAYMENTDATE FROM table1 where DATE IN (SELECT ID FROM _DATE WHERE ID = ( SELECT MAX(ID) FROM _DATE WHERE ID < ( SELECT MAX(ID) FROM _DATE ) ))");
String reportingUnit = ("SELECT REPORTING_UNIT FROM table1 where DATE IN (SELECT ID FROM _DATE WHERE ID = ( SELECT MAX(ID) FROM _DATE WHERE ID < ( SELECT MAX(ID) FROM _DATE ) ))");
String insertLastDate = ("INSERT INTO table1(PAYMENTDATE, REPORTING_UNIT, Date) VALUES ("+paymentDate+", "+reportingunit+", "+asOfDate+")");
getSession().createQuery(paymentDate);
getSession().createQuery(reportingunit);
}
I'm calling the code using the code below. I cant figure out where the null value is coming from, I tried debugging but the program crashes before getting anything useful
AdjustmentHibernate AdjustmentHibernate = new AdjustmentHibernate();
AdjustmentHibernate.addPrevious(asOfDate);