Skip to content
Advertisement

JPA Entity Class using class object as parameter

I have a class User which has a parameter of another class type ShoppingList. As this…

JavaScript

How can i make this ManyToOne relationship while the variable being an array? The idea is to have a User table and another ShoppingList table, so the user can have multiple lists at the same time.

Advertisement

Answer

This would be the correct way:

One Employee has many ShoppingLists.

One ShoppingList has only one Employee.

JavaScript
JavaScript

You can fine-tune your entities as per your need. For more info, I would refer to this tutorial, it has helped me a lot.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement