Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

one to one mapping in hibernate..exception while saving.

 
vani venkat
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic