aspose file tools*
The moose likes JSF and the fly likes Inserting list(ArrayList) data on multivalued attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Inserting list(ArrayList) data on multivalued attribute" Watch "Inserting list(ArrayList) data on multivalued attribute" New topic
Author

Inserting list(ArrayList) data on multivalued attribute

Deepak Naithani
Greenhorn

Joined: Aug 30, 2012
Posts: 25


Tables
CREATE TABLE employee (emp_Id INTEGER PRIMARY KEY AUTO_INCREMENT,
firstName VARCHAR(20),
lastName VARCHAR(20),
address VARCHAR(30),
DOB DATE,
sex VARCHAR(8),
country VARCHAR(15),
state VARCHAR(20));

CREATE TABLE emp_hobbies(emp_Id_ref INTEGER,
hobbies VARCHAR(10),
FOREIGN KEY (emp_Id_ref) REFERENCES employee(emp_Id));

I have these two tables where i want to enter values of selected hobbies "selectHobbies" into emp_hobbies so how should i do it, is there a method to directly enter the data to column from list or should i use String array to hold this value for entering to database.

Also there is a dependency between table, so for first attribute how should enter the value of emp_Id to emp_Id_ref.

I'm getting the key from table


with this key i want to enter the ArrayList data to table emphobbies.

for example
emp_Id_ref hobbies
1                  reading
1                  running
1                  cricket
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Inserting list(ArrayList) data on multivalued attribute