Home > OS >  How to store List using PostgreSQL in Java Springboot JPA?
How to store List using PostgreSQL in Java Springboot JPA?

Time:06-07

I'm new to Java related techniques, and I currently working on a SpringBoot Project, and I need to store a list of numbers, such as 'XXXXX':[1,2,3,4...], but the result is not what I want.

Here is my entity:

enter image description here

This is the repository class:

enter image description here

This is how I save the data in my project:

enter image description here

And this is the final result that the data store in the database:

enter image description here

I don't want data stored in such style, cause I may need to get time_slot_list using connectio_id. It would increase my program complexity. How could I fix it? If there is some information is ambiguity, please let me, I would fix that. Thanks in advance.

CodePudding user response:

There is no need to 'fix' something. It's the correct way to store a List for an entity in a relational database. Just take a look at database normalization. I understand that it might look unnecessary at first but this way is better to work with over all.

  • Related