• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

one to many relation error

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone! I�m newbe using Hibernate and I�m trying to figure out where�s my mistake mapping a one-to-may relation. I�ve been the last hours trying to solve it but I couldn�t, so I decided to ask you. Please any suggestion will help me a lot!!

I explain you the bussines logic here:
every user has one or more passwords, and a password can be removed from a user.

I know that my post it�s a quite long but I tried to provide you everything you should need...

So here�s the User class:


Here the Password class



Here the User mapping xml:


Here�s the hibernate config:


Here where I�m creating the user:


And finally here�s the stack trace:


Thanks in advance for your help!!!
Regards!!!
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

At first glance it would seem that you are violating some database contraint.

Caused by: java.sql.BatchUpdateException: Duplicate entry '2' for key 1

It would appear that you are inserting into a table that already has a key value i.e. '2'
 
Not so fast naughty spawn! I want you to know about
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic