【发布时间】:2017-04-11 16:43:43
【问题描述】:
@Entity
@Table(name = "USER_INFO")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "USER_ID")
private int userId;
@OneToOne
@JoinColumn(name = "CGH_SOE_ID", referencedColumnName = "CGH_SOE_ID", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
@Fetch(FetchMode.JOIN)
private UserDimension userDimension;
.......
@Entity
@Table(name = "USER_DIMENSION")
public class UserDimension {
@Column(name = "EMPLID", length = 11)
private String employeeLid;
@Id
@Column(name = "CGH_SOE_ID", length = 10, nullable = false)
private String CGHSOEId;
我使用 Criteria 查询从数据库中获取用户对象,并且用户维度与之关联。
1) 当我从数据库中获取用户对象时,我只想从 UserDimension 中获取 2-3 列。
2) 我可以在所有列获取和选定列获取之间动态切换吗?
谢谢
【问题讨论】:
标签: java spring hibernate jpa hibernate-criteria