I'm learning spring boot and trying to figure out how should I describe the dependency.
I'm aware that dependency injection is one of the core features of Spring framework.
How should I describe dependency in coding?
For example, I have two classes, Company and Address
@Entity
public class Address {
@Id
@GeneratedValue
private int id;
private String street;
private int number;
}
the Company class depends on Address, how do I describe such dependency?
should I go with addressId
@Entity
public class Company {
@Id
@GeneratedValue
private int id;
private String name;
private int addressId;
}
or the Address object itself
@Entity
public class Company {
@Id
@GeneratedValue
private int id;
private String name;
private Address address;
}