假设我有一个名为“Team”的SQL DO,它有一个名称,描述,ID和个人资料图片。
它看起来像这样:
@Entity
@Table(name = "Team")
public class TeamDO implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="team_id")
private Long id;
private String description;
private String name;
@ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name="user_id", nullable = false)
private Users users;
public TeamDO() {}
public TeamDO(Users user) {
this.setUsers(user);
}
@Override
public String toString() {
return String.format(
"TeamDO[id=%d, inital='%s', description='%s', name='%s']"
, getId()
, getUsers().getInitialName()
, getDescription()
, getName()
);
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Users getUsers() {
return users;
}
public void setUsers(Users users) {
this.users = users;
}
}
什么样的变量存储jpg这样的文件?或者我的POJO会有一个String profilePictureURL,用于获取每个团队的图像(徽标)吗?
答案 0 :(得分:1)
首选将文件存储在某种托管服务中,只保存数据库中的URL,但也可以将其保存为字节数组。