• 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 one mapping in hibernate..exception while saving.

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have one to one relation between user and candidate. ideally user is used for authentication purposes and candidate holds all other information. i defined many to one relation in candidate hm file. when i try to save candidate bean, it gives lock wait time out exception. can some one point out what the problem is. i searched and could not get good infromation of solution for this.

Here are the hbm files.
User.hbm.xml


Candidate.hbm.xml


candidate.java


private User candidateUserId;
public User getCandidateUserId() {
return candidateUserId;
}

public void setCandidateUserId(User candidateUserId) {
this.candidateUserId = candidateUserId;
}




saving candidate bean in DAO.

 
vani venkat
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I restarted Jboss server and here is the new exception.
is there anything wrong with mapping?

15:46:21,259 INFO [STDOUT] Hibernate: insert into CSS_User (userId, password, f
irstName, lastName) values (?, ?, ?, ?)
15:46:21,291 INFO [STDOUT] Hibernate: insert into css_candidate (firstName, las
tName, emailId, businessPhone, homePhone, cellPhone, street, apt, city, state, z
ip, country, createDate, modifiedDate, userId) values (?, ?, ?, ?, ?, ?, ?, ?, ?
, ?, ?, ?, ?, ?, ?)
15:46:21,291 WARN [org.hibernate.util.JDBCExceptionReporter] SQL Error: 1452, S
QLState: 23000
15:46:21,291 ERROR [org.hibernate.util.JDBCExceptionReporter] Cannot add or upda
te a child row: a foreign key constraint fails (`ssln`.`css_candidate`, CONSTRAI
NT `FK_Candidate_userId` FOREIGN KEY (`userId`) REFERENCES `css_user` (`userId`)
ON UPDATE CASCADE)

why is it not creating record in css_user table? should i save user too?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic