与>>条件(不等于)返回错误的行
HQL语句:
String hql = "SELECT DISTINCT track FROM TrackEntity track " +
"LEFT JOIN track.releaseRelations releaseRelation " +
"LEFT JOIN releaseRelation.release.publisherProducerArtists releaseArtist " +
"LEFT JOIN releaseArtist.person releaseArtistPerson " +
"LEFT JOIN releaseRelation.release.publisherProducerGroupCasts releaseGroupCast " +
"LEFT JOIN releaseGroupCast.artistRelations releaseGroupCastArtistRelations " +
"LEFT JOIN releaseGroupCastArtistRelations.artist.person releaseGroupCastPerson " +
"WHERE (releaseArtistPerson.id <> " + personId +
" OR releaseArtistPerson.id IS null) " +
"AND (releaseGroupCastPerson.id <> " + personId +
" OR releaseGroupCastPerson.id IS null ) "
目标是找到与人无关的所有轨道。因此,该人不应在PublisherProducerartists和PublisherProducerGroupcast中。
statement滤波仅滤除了人格与人体相等的一排。但是,如果一行相等,则该轨道的所有行都应被过滤掉。 可能我需要类似的东西吗?但是后来我必须使用子选择权吗?
解决这个问题的常见方法是什么?
感谢您的帮助:)
HQL Statement:
String hql = "SELECT DISTINCT track FROM TrackEntity track " +
"LEFT JOIN track.releaseRelations releaseRelation " +
"LEFT JOIN releaseRelation.release.publisherProducerArtists releaseArtist " +
"LEFT JOIN releaseArtist.person releaseArtistPerson " +
"LEFT JOIN releaseRelation.release.publisherProducerGroupCasts releaseGroupCast " +
"LEFT JOIN releaseGroupCast.artistRelations releaseGroupCastArtistRelations " +
"LEFT JOIN releaseGroupCastArtistRelations.artist.person releaseGroupCastPerson " +
"WHERE (releaseArtistPerson.id <> " + personId +
" OR releaseArtistPerson.id IS null) " +
"AND (releaseGroupCastPerson.id <> " + personId +
" OR releaseGroupCastPerson.id IS null ) "
The goal is to find all tracks where the person is not related to. So the person should not be in the publisherProducerArtists and publisherProducerGroupCasts.
The WHERE-statement filters out just the one row where the personId is equal. But if one row is equal, all rows of this track should be filtered out.
Probably I need something like NOT IN? But then I have to use SUBSELECTs right?
What is the common way to solve this?
Thanks for help :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
需要理解以下语句:
当Persion的ID不等于给定的数字/字符串作为PersionId时,第一个表达式(与操作员的复合表达式的连接)将返回true,这也意味着如果Persion的ID为null,则选择该记录。
因此,首先需要删除或在与之检查的地方进行null。
如果仍然存在问题,请尝试不在与HQL合作的操作员中,例如:
Need to understand the below statement:
The first expression (of composite expression joined with OR operator) will return true when Persion's Id is not equals to given Number/String as PersionID which also means if Persion's Id is Null then also that record is selected.
Therefore, first need to remove OR section where checking with IS Null.
If still issue persists, try Not In operator which works with HQL like: