Craig Star

Greenhorn
+ Follow
since Jan 24, 2021
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Craig Star

hello,

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?



properties



1 week ago
After some thought I understand.
If in any case there should be such a requirement, it would point a reference to the total in the Customer pojo
2 months ago
thank you, I understand now where I was wrong.
A customer is one and accounts are many.
Still, if I would have wanted to have a variable in each account, as "totalForAllAcounts", how would that be achievable?

customer: details
Account: details of the account + new field totalOfAllAccounts



I can solve the sew field in the customer.
2 months ago
Hello,

I need to process my array list and calculate the total that is take from each account balance.
I can't have another data structure as per homework.



POJO's



First though was to loop over the list and



This does not work as the previous total is added to the next customer.

A potential solution would be to add an accountKey to the Customer and Account, so I can have a constant in both lists, to check if they match and calculate the total.
Maybe that would stop the addition of balance to the next customer.
I don't think that is a go, tho.

Thank you for reading.
2 months ago