1

Possible Duplicate:
Hibernate: different object with the same identifier value was already associated with the session

I tried to save two entity once:

session=....getCurrentSession();

Book bo1=new Book();
bo1.setName("name1");
session.save(bo1);

Book bo2=new Book();
bo2.setName("name2");
session.save(bo2);

Then I get a exception:

a different object with the same identifier value was already associated with the session.

Seems that the bo2' identifier exist (the bo1's identifier), I wonder why?

BTW, I really want to know more about the session in hibernate, any docs? I have read the tutorial of hibernate, but it is not detailed enough.

Community
  • 1
  • 1
hguser
  • 35,079
  • 54
  • 159
  • 293

1 Answers1

0

You need to provide Book mapping. I difficult to know what can happen behind the scenes if you just show some snippet of code. We help you if you help us. But a good intro to SessionFactory/Session is shown here. Good lucky!

Arthur Ronald
  • 33,349
  • 20
  • 110
  • 136
  • Thanks I got it, I found that it is caused by the type of the generator,I set it to identify,and it work now. – hguser Nov 01 '10 at 13:15