• 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 ...
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown

Mapping and querying with JPA/Hibernate SpringBoot

Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Please consider this scenario

my models

I have a very simple repository and controller just to test how the data is persisted

I would like to save a record like this using the /load endpoint

   "id": 2,
   "firstName": "Cris",
   "lastName": "Star",
   "middleName": "None",
   "alias": "Cr",
   "dateOfBirth": "2020-02-12",
   "gender": "male",
   "contactDetails": {
       "emailAddress": "cris@javaranch.com"

What I get now is

       "id": 2,
       "firstName": null,
       "lastName": null,
       "middleName": null,
       "alias": null,
       "dateOfBirth": null,
       "gender": null,
       "contactDetails": {
           "id": 8,
           "emailAddress": "hello",
           "mobileTelNo": null,
           "homeTelNo": null,
           "workTelNo": null,
           "employee": null,
           "new": false
       "new": false

When I query the MySql data base I can see the record added in the customer_details table.

End goal:
1. save employee details and persist data in contact_details table
2. search by phone_number and list the details(either customer or employee) of the related phone number
3. search by employee_id or customer_id and get customer/employee + contact details back

How could i map my model to start with?
Could anyone help me with the queries, please?


    Bookmark Topic Watch Topic
  • New Topic