Hi,
I have read the "Collection" chapter in hibernate doc. And I still dont get how to save a vector / list of objects into a table.
OKay basically I have this table, this is just a mock SQL create statement to show how the table look like so the SQL statement might not work
Create table address (
ADDRESS_ID BIGINT AUTO_INCREMENT
USER_ID varchar2(50),
STREET VARCHAR2(300),
FOREIGN KEY USER_ID REFERENCES USER(USER_ID)
)
My user may have more than 1 addresses. And from my Form Class I will return a vector/list/arrray of addresses to be saved to the table.
Do I need to loop the vector/list and save the object 1 by 1 or Can I use HIbernate to persist the vector ?
My Address object will be something like this:
Code:
public class UserAddress implements AbstractPersister {
ArrayList addrList = new ArrayList();
/* (non-Javadoc)
* @see AbstractPersister#getPersisterClass()
*/
public Class getPersisterClass() {
return UserAddress.class;
}
/**
* @return
*/
public ArrayList getAddrList() {
return addrList;
}
/**
* @param list
*/
public void setAddrList(ArrayList list) {
addrList = list;
}
}
[/code]