Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning 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
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

one-to-one mapping.

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
i am beginner to hibernate. please guide me with one to one mapping.

DB table structure:





Employee.java



EmployeeContact.java


Employee.hbm.xml


EmployeeContact.hbm.xml


Here in EmployeeBean.java, i construct employee object



Here in EmployeeDaoImpl.java i save the employee object





The problem is one to one mapping. The EmployeeContact object gets saved except employee_id. EMPLOYEE_ID remains null in EMPLOYEE_CONTACT table. Please guide me where the configuration is fallen short.
 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why are you using "property-ref" in your Employee mapping ?
It is not necessary to establish the one-to-one relationship unless you work with legacy database.
It could be the problem.
 
harshad kadam
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

ntumba lobo wrote:why are you using "property-ref" in your Employee mapping ?
It is not necessary to establish the one-to-one relationship unless you work with legacy database.
It could be the problem.




I reffered "property-ref" from this tutorial.

As per your advice i removed "property-ref" but didn't work for me. Problem persists.
 
I didn't do it. You can't prove it. Nobody saw me. The sheep are lying! This tiny ad is my witness!
ScroogeXHTML 8.7 - RTF to HTML5 and XHTML converter
https://coderanch.com/t/730700/ScroogeXHTML-RTF-HTML-XHTML-converter
    Bookmark Topic Watch Topic
  • New Topic