Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add list of Strings to entity - Spring, Hibernate

I have Spring Boot project with DB. I've already get table, let's call it "People". I need to add a second table "People_Strings" with two columns: People_id and String. I need to include many strings for every row from People.

How can I map it in my People entity in project?

Edit: I need to do this without creating separete class for String or for People_Strings

like image 860
Alex Avatar asked Oct 27 '25 04:10

Alex


1 Answers

If you only need that, you can add the following property to the People entity class:

@ElementCollection
public List<String> strings;
like image 120
Ramsés J Avatar answered Oct 29 '25 18:10

Ramsés J



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!