Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible typo in lesson S3-M3-L2 #184

Open
evil-face opened this issue Sep 13, 2023 · 1 comment
Open

Possible typo in lesson S3-M3-L2 #184

evil-face opened this issue Sep 13, 2023 · 1 comment

Comments

@evil-face
Copy link

evil-face commented Sep 13, 2023

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<>();
    // ...
}
@blbulyandavbulyan
Copy link

Yeah, I noticed this as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants