This week's book giveaways are in the Jython/Python and Object-Oriented programming forums.
We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

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

 
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?
 
Dinner will be steamed monkey heads with a side of tiny ads.
Level Up Your Code with a Pro Java IDE
https://www.jetbrains.com/idea
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!