I'm not really sure how to map the following case with the latest hibernate. I have two objects: a Table class and a TableRow class. I included the basic definition of each one. Table is an entity and TableRow is a value type. The complexity comes from TableRow using a Map to store the column names and values. We want to map each column name and value in TableRow to TABLE_DATA. The column names are the hashmap keys. We have two tables in our database right now: DOC_TABLE and a second, TABLE_DATA, with a foreign key to the DOC_TABLE primary key. Any suggestions? I couldn't find a good example in the documentation that covers this specific case. Thanks.
Code:
DOC_TABLE columns:
TABLE_ID
NAME
DESCRIPTION
CAPTION
TABLE_DATA columns:
TABLE_ID (FK)
COL_NAME
COL_DATA
ROW_INDEX
Code:
public class Table implements PersistentEntity {
private Integer tableId;
private String name;
private String description;
private String caption;
private List<TableRow> tableRows = new ArrayList<TableRow>();
public Integer getId() {
return tableId;
}
private void setId(Integer id) {
this.tableId = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getCaption() {
return caption;
}
public void setCaption(String caption) {
this.caption = caption;
}
public void addRow(TableRow row) {
}
public List getRows() {
return null;
}
public void setRows(List tableRows) {
}
}
public class TableRow {
private Map<String, String> rowData;
public TableRow() {
}
public String getColumnValue(String columnName) {
return null;
}
public void setColumnValue(String columnName, String columnValue) {
}
public Map getRowData() {
return null;
}
public void setRowData(Map rowData) {
}
}