0

I m wondering how can i map a class having arrayList which should keep its values to another table. Let take some code for example.

Class Person
{
int id;
String name;
ArrayList<String> childNames

}

in db has 2 tables 1. Person -> storing id and name 2. Childs -> storing child name and id //pseudo Object A

id;
name Ivan
ArrayList childs = new ArrayList();
childs.add("Peter");
Chidls.add("Lora");

so in db it shoud looks like

Table Person
id name 
1   Ivan

Table Childs
id    name
1     Peter
1     Lora

But using annotations, any suggestions?

Regards thanks

1 Answer 1

1

Use @IndexColumn annotation. Also prefer List interface over ArrayList, Hibernate uses some specific implementations of this interface.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Tomasz ,i will check it out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.