我正在使用Hibernate来连接实体之间的列,并且我想使用连接的列来连接第二个实体,并且仅包括具有值的第二个实体。
即实体1 userSessionReports
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
@JoinColumn(name = "guide_id", updatable = false)
@LazyCollection(LazyCollectionOption.FALSE)
@Where(clause = "userResults IS NOT NULL OR userTracking IS NOT NULL")
private List<UserSessionReportDetail> userSessionReports = new ArrayList<UserSessionReportDetail>();
包含这2个连接的列
@OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = "user_session_id", updatable = false)
@LazyCollection(LazyCollectionOption.FALSE)
private List<UserResult> userResults = new ArrayList<UserResult>();
@OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = "user_session_id", updatable = false)
@LazyCollection(LazyCollectionOption.FALSE)
private List<UserTracking> userTracking = new ArrayList<UserTracking>();
我正在尝试仅通过“ where”条件获取存在userResults或userTracking的userSessionReports。
我尝试过
@Where(clause = "userResults IS NOT NULL OR userTracking IS NOT NULL")
@Where(clause = "userResults IS NOT EMPTY OR userTracking IS NOT EMPTY")
@Where(clause = "userResults.size() > 0 OR userTracking.size() > 0")
这些都不起作用。
尝试.size()时出现错误execute command denied to user 'webuser'@'%' for routine 'userresults.size'
任何简单的解决方案?