我有一个实体 Note 和组件 FavoriteNote,这是表定义:
CREATE TABLE NOTE (
ID INTEGER,
TITLE VARCHAR(100) CHARACTER SET UTF8,
CONTENT BLOB SUB_TYPE 1 CHARACTER SET UTF8,
TYPE_NO INTEGER,
DEL SMALLINT,
CREATE_DATE TIMESTAMP,
UPDATE_DATE TIMESTAMP);
CREATE TABLE FAVORITE (
NOTE_NO INTEGER NOT NULL,
DROP_IN_DATE DATE);
和java代码是:
public class FavoriteNote {
private Note note;
private Date dropInDate;
public Note getNote() {
return note;
}
public void setNote(Note note) {
this.note = note;
}
public Date getDropInDate() {
return dropInDate;
}
public void setDropInDate(Date dropInDate) {
this.dropInDate = dropInDate;
}
}
public class Note implements Serializable {
private static final long serialVersionUID = -8363339156398741610L;
private int id;
private String title;
private String content;
private String typeName;
private int del;
private int show;
private NoteType noteType;
private BeanState beanState;
private Date createDate;
private Date updateDate;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public int getDel() {
return del;
}
public void setDel(int del) {
this.del = del;
}
public int getShow() {
return show;
}
public void setShow(int show) {
this.show = show;
}
public NoteType getNoteType() {
return noteType;
}
public void setNoteType(NoteType noteType) {
this.noteType = noteType;
}
public String getTypeName() {
return typeName;
}
public void setTypeName(String typeName) {
this.typeName = typeName;
}
public BeanState getState() {
return beanState;
}
public void setState(BeanState beanState) {
this.beanState = beanState;
}
@Override
public String getClassName() {
return "Note";
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public Date getUpdateDate() {
return updateDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
}
问题是 FavoriateNote 不是 Note 的一部分,它们只是一对一的关联。如何配置关联以使检索所有收藏夹成为可能?最好以xml方式完成。
谢谢