#Problem with null values in @Embedded fields

8 messages · Page 1 of 1 (latest)

pseudo elm
#

Hello, I have return values, but when I save an object to database and return this then I have those values assigned

//companydata
@Entity
@Setter
@Getter
public class Customer {
    @Id
    @GeneratedValue(
            strategy = GenerationType.AUTO
    )
    private Long id;
    @Embedded
    private PersonalData personalData;
    @Embedded
    private CompanyData companyData;
}
//companydata
@Getter
@Setter
@Embeddable
@EqualsAndHashCode
public class CompanyData {
    private String companyName;
    @Embedded
    @Column(name = "company_address")
    private Address address;
    @Embedded
    @Column(name = "company_contact_data")
    private ContactData contactData;
    @Nullable private String nip;
    @Nullable private String regon;
}

//personaldata
@Getter
@Setter
@EqualsAndHashCode
@Embeddable
public class PersonalData {
    private String name, surname;
    @Embedded
    private Address address;
    @Embedded
    private ContactData contactData;
    private String pesel;
}


Here is return code

public Customer getCustomer(Long customerId){
        Optional<Customer> optionalCustomer = customerRepository.findById(customerId);
        if (optionalCustomer.isEmpty()) {
            throw new ApiNotFoundException("Customer not found");
        }
        return optionalCustomer.get();
    }
steady cryptBOT
#

This post has been reserved for your question.

Hey @pseudo elm! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

pseudo elm
#

when I create an customer

#

when I want to get customer

#

If someone want help ping me, and thanks to anyone who would like to help 😄

steady cryptBOT