2016-11-23 4 views
2

私は特定のユーザーの行を更新するためにspring data restを使用したいが、実行時にはこのクエリーにクエリに奇妙な "クロスジョイン"が追加されています。spring data rest updateプロデュースクロスジョインSQLエラー

春データ休息方法

@Modifying 
@Transactional 
@Query("Update Notification n SET n.noticed = true Where n.notificationPost.owner.userId = 1 ") 
public void postNoticed(); 

実行時に作成クエリ

Hibernate: update notification cross join set noticed=true where owner_id=? 

それは私が呼ん

org.postgresql.util.PSQLException: ERROR: syntax error at or near "cross" 

SQLエラーを与えるとして追加 "クロス結合" なぜ私の唯一の懸念はありますこのメソッドは、直接残りの呼び出しによって、また、mvcコントローラから、両方の方法で同じエラーが発生する

ありがとうございます。

+0

を使用するように私のコードを編集した – Blank

答えて

2

http://forum.spring.io/forum/spring-projects/data/114271-spring-data-jpa-modifying-query-failureで述べたように見つかった溶液

「いいえは、暗黙的または明示的のいずれかで、結合、バルクHQLクエリで指定することができる。サブクエリはサブクエリ自体が含まれていてもよいWHERE句で使用することができますジョイン「(DOC参照休止状態:http://docs.jboss.org/hibernate/core.../#batch-directを)。」。

だから私は、私たちにいくつかのエンティティのコードスニペットを表示するサブクエリ

@Modifying 
@Transactional 
@Query("Update Notification n SET n.noticed = true Where n.notificationPost.postId in (SELECT n2.notificationPost.postId FROM Notification n2 where n2.notificationPost.owner.userId =:#{#security.principal.user.userId}) ") 
public int postNoticed(); 
+0

これが唯一のDMLスタイルの操作に適用されます。 – Alex78191

関連する問題