级联关系:
package com.bbg.fms.model;
import java.util.Date;
import java.util.List;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.annotations.GenericGenerator;
import com.bbg.framework.AbstractEntity;
/**
* @author Rangey
*/
@Entity
@Table(name="BBG_FMS_FILE_INFO")
public class FileInfoPo extends AbstractEntity<String> {
@Transient
private static final long serialVersionUID = -7497235305117364771L;
@Id
@Column(name = "ID", length=36)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
private String id;
@Column(length=50)
private String fileName;
@Column
private Long fileSize;
@Column(length=50)
private String moduleName;
@Column(length=10)
private String version;
@Column
private Date createTime;
@Column(length=10)
private String fileType;
@Column
private String remark;
@ElementCollection
@CollectionTable(name = "BBG_FMS_FILE_SLICE", joinColumns = @JoinColumn(name = "FILE_ID"))
@OrderBy("pos")
private List<FileSlice> slices;
@ElementCollection
@CollectionTable(name = "BBG_FMS_FILE_PROP", joinColumns = @JoinColumn(name = "FILE_ID"))
private List<FileProp> props;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public Long getFileSize() {
return fileSize;
}
public void setFileSize(Long fileSize) {
this.fileSize = fileSize;
}
public String getModuleName() {
return moduleName;
}
public void setModuleName(String moduleName) {
this.moduleName = moduleName;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getFileType() {
return fileType;
}
public void setFileType(String fileType) {
this.fileType = fileType;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public List<FileSlice> getSlices() {
return slices;
}
public void setSlices(List<FileSlice> slices) {
this.slices = slices;
}
public List<FileProp> getProps() {
return props;
}
public void setProps(List<FileProp> props) {
this.props = props;
}
@Override
public String getObjectId() {
return id;
}
}
package com.bbg.fms.model;
import javax.persistence.Column;
import javax.persistence.Embeddable;
/**
*
* @author Rangey
* @version 1.0
*
*/
@Embeddable
public class FileSlice {
@Column(length=21800)
private String data;
@Column
private int seqNo;
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public int getSeqNo() {
return seqNo;
}
public void setSeqNo(int seqNo) {
this.seqNo = seqNo;
}
}
package com.bbg.fms.model;
import javax.persistence.Column;
import javax.persistence.Embeddable;
/**
*
* @author Rangey
* @version 1.0
*
*/
@Embeddable
public class FileProp {
@Column
private String keyword;
public String getKeyword() {
return keyword;
}
public void setKeyword(String keyword) {
this.keyword = keyword;
}
}