如果为主键关联, 在hibernate中当关系为1-1时候 并且此表的主键为外键的时候 则设置的属性为
/**
* @hibernate.id generator-class = "foreign"
* @hibernate.generator-param name = "property" value = "workItem"
* @return
*/
public Long getId() {
return id;
}
/**
* @hibernate.one-to-one constrained = "true"
* @return
*/
public WorkItem getWorkItem() {
return workItem;
}
当为一对多的时候
/**
* 按id排序,不要修改。
*
* @hibernate.bag cascade = "all" order-by="id" inverse="true"
* lazy="true"
* @hibernate.collection-key column = "app_instance_id"
* @hibernate.collection-one-to-many class = "cn.bidlink.workflow.app.inst.AppFieldInstance"
*
* @return
*/
public List getFields() {
return fields;
}
当为多对一的时候
/**
* @hibernate.many-to-one column="performer_id"
* @return
*/
public User getPerformer() {
return performer;
}
public void setPerformer(User performer) {
this.performer = performer;
}
如果不能为空的情况
/**
*
* @hibernate.many-to-one column = "definition_id" not-null = "true"
* @return
*/
public AppDefinition getDefinition() {
return definition;
}
在表头是@hibernate.class table="app_field_instances"