Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,899 members, 7,817,661 topics. Date: Saturday, 04 May 2024 at 04:39 PM

How Do I Go About This System Design ? - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / How Do I Go About This System Design ? (424 Views)

I Want My Son To Be A Programmer, How Do I Go About It / Backend Software Engineers, Let's Talk About System Design / Should I Go For Cybersecurity Or Computer Science? (2) (3) (4)

(1) (Reply) (Go Down)

How Do I Go About This System Design ? by sweetguy10(m): 6:53pm On Aug 07, 2022
Good day everyone , I have this Java/Spring boot project where I need to return objects values in XML . The thing is most of the variables to be returned have their fixed final variables values already , how do I go about not persisting them in the database but can call them anytime that I need to add them up to a payload for a POST operation? This is a sample of how the response payloads should be like .

<person>
<contact>
<number>09087431264</number>
<age>30</age>
</contact>
</person>

As you can see the number and age fields in the contact class are fixed final variables inside the person object which is an entity. I used @Embeddable and @Embedded to add the Contact class to the Person entity but it added the column : Number and Age to the Person entity and making a REST call to the Person entity will not return the person entity with the XML schema as posted above . Inputs and help will be greatly appreciated .

@richebony your input as well will be greatly appreciated sir thanks much.
Re: How Do I Go About This System Design ? by richebony: 9:34am On Apr 07, 2023
sweetguy10:
Good day everyone , I have this Java/Spring boot project where I need to return objects values in XML . The thing is most of the variables to be returned have their fixed final variables values already , how do I go about not persisting them in the database but can call them anytime that I need to add them up to a payload for a POST operation? This is a sample of how the response payloads should be like .

<person>
<contact>
<number>09087431264</number>
<age>30</age>
</contact>
</person>

As you can see the number and age fields in the contact class are fixed final variables inside the person object which is an entity. I used @Embeddable and @Embedded to add the Contact class to the Person entity but it added the column : Number and Age to the Person entity and making a REST call to the Person entity will not return the person entity with the XML schema as posted above . Inputs and help will be greatly appreciated .

@richebony your input as well will be greatly appreciated sir thanks much.


lol do u know i am just seeing this shit now, anyways heres my take if it would help anyone facing a similar problem . I think using @Embbeded just injects fields parameters to a parent class creating columns on the fly. using @Transient may help


@Entity
public class Person{

@Id
private Integer id;

// native fields

@Transient
public Contact contact

// getters and setters
}

1 Like

Re: How Do I Go About This System Design ? by Deicide: 7:06pm On Apr 07, 2023
XML why?
Re: How Do I Go About This System Design ? by CodeTemplar: 7:48pm On Apr 07, 2023
There is an SQL formula for age calculation and.an annotation for it within your Bean. I can't remember now. DOB is fixed so the an notion takes the date of birth and su tract current date from it them divide by 365 to get age.

I suspect OP is just cruising.

You could also implement the logic inside the getter method of the age field.

(1) (Reply)

Get An E-commerce Site Like Jumia For ₦17k / The Future Of Technology: What To Expect In The Coming Years / .

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 15
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.