posted 16 years ago
Hi all,
I have stuck with this problem.Please help me.
I have a table goals_01 in which ID and GOALCODE form a composite key in ORACLE DB.
I am using MyEclipse. I have selected increment as id generator while reverse engging from tables.
I thought id will be increment automatically but it gave me an error that you have assign id a value manually.
Since i dont have the max value in the begining i tried to get the max value of id by using HQL.below is the query.
{
Query query = hsession.createQuery("select max(Goals01.id) from Goals01 ");
List lis = query.list();
maxID = ((Integer)lis.get(0)).intValue();
}
here Goals01 is the pojo class.but i am getting a nullpointer exception at the 1st line.i thought since no value existed it is throwing an exception.
I inserted one row manually and tried again.but got the same .
Please help me to resolve this or any other way i can handle incrementing or assigning composite ids in hibernate.Example will be very helpful
Thanks in adavance