Win a copy of Penetration Testing Basics this week in the Security forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic


Brian Oleksa
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get this error when I try to persist to the DB an arraylist of beans

11:19:16,375 ERROR [STDERR] javax.persistence.PersistenceException: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session:[com.darcorner.mina.beans.WindowBean#0]

Here is my code...

public void save(ArrayList<WindowBean> beans) {

try {

int size = beans.size();
System.out.println("this is the size .." + size);

for (int i = 0; i < beans.size(); i++) {

String name = beans.get(i).getName();
int startTime = beans.get(i).getStartTime();
int stopTime = beans.get(i).getStopTime();

System.out.println("this is what is in thename .." + name);
System.out.println("this is what is in the starttime .."+ startTime);
System.out.println("this is what is in the stoptime .."+ stopTime);

WindowBean windowbean = new WindowBean();



} catch (Exception e) {

I have the data that the user entered in. I know this for a fact because it loops through my system.out's and gives me the data.

So all I want to do is insert all the data in each bean into the DB.
The code works great if there is only one bean in the ArrayList, but if there is more than one, I get the above error.

Any thoughts...???


  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic