How can I remove an object from hibernate session? In my code I am fetching one list from the DB and searching if the user entered data is already there in the DB. If it is there I am overwriting it. Else I am creating a new object and saving it. But the jboss shows error that there are two objects in session. As far as i guess one object is the object that iterates through the list and other is the one newly created for saving the data.
for(Allocation al: allocatelist){
if(al.getDate().compareTo(dt)==0){
al.setAllocated(gpsz);
getManager().save(al);
flag=1;
break;
{
{
If the above condition fails then am creating and new object and saving it. So is there any way by which I can remove this object "al"? I don't have merger or update methods I have tried "evict()" also but its of no use. The else block
Allocation allocate = new Allocation();
allocate = filldata(allocate, dataMap,i);
getManager().save(allocate);
filldata() fills the inputs into the object.`