我在这里有下表,但在获取结果时遇到了一些问题。
@Entity
@Table(name = "USER_VW")
public class WorkspaceUserImpl
{
@JoinColumn(name = "USER_ID", insertable=false, updatable=false)
@OneToOne(targetEntity = UserImpl.class, fetch = FetchType.EAGER)
private User user;
}
@Table(name = "IK_USER")
@Inheritance(strategy = InheritanceType.JOINED)
@AttributeOverride(name = "id", column = @Column(name = "USER_ID") )
public class UserImpl extends BaseAuditable<UserIdentifier>implements User, UserAuthentication {
private static Logger log = LoggerFactory.getLogger(UserImpl.class);
@Id
@Type(type = "com.commons.UserIdentifierTypeMapper")
@Column(name = "USER_ID")
private UserIdentifier id;
}
和用户
Public Inteface User
{
UserIdentifier getId();
}
现在我编写了一个HQL查询来从WorkspaceUserImpl类中获取所有数据,并为UserImpl类提供给定的用户ID,如下所示。
SELECT w from WorkspaceUserImpl w where w.user.id = : user_id;
并尝试了
SELECT w from WorkspaceUserImpl as w INNER JOIN w.user as u where u.id = : user_id;
甚至尝试使用JOIN FETCH
并将参数 user_id 设置为1234。
但是我得到了List作为部分ID的emply,但在DB中它有5个记录。
我在这里犯了任何查询错误吗?善意的建议..答案 0 :(得分:0)
您是否尝试过以下查询:
from WorkspaceUserImpl as w JOIN FETCH w.user as u where u.id = : user_id;