-
Notifications
You must be signed in to change notification settings - Fork 213
Open
Description
Hi there, I wanted to know if there was a typo in lesson about One-to-one relationships.
I'm talking about mappedBy="customerId"
. Isn't it supposed to be simply "customer"
in this case?
@Entity
public class Customer {
// ...
@OneToOne(mappedBy="customerId")
private Address address;
// ...
}
@Entity
public class Address {
@Id
private Long id;
private String description;
@OneToOne
private Customer customer;
// ...
}
UPD:
Same in Many-to-many relationships:
@Entity
public class Order {
@Id
private Long id;
private Date date;
Decimal amount; // btw, BigDecimal?
@ManyToMany
@JoinTable(name="ORDER_ITEM",
joinColumns=@JoinColumn(name="ORDER_ID"),
inverseJoinColumns=@JoinColumn(name="ITEM_ID"))
private Set<Item> items = new HashSet<>();
// ...
}
@Entity
public class Item {
@Id
@GeneratedValue
private Long id;
private String name;
@ManyToMany(mappedBy = "orders") // should be "items"?
private Set<Order> orders = new HashSet<>();
// ...
}
Metadata
Metadata
Assignees
Labels
No labels