覆盖 @Where JPA 注解

huangapple 未分类评论46阅读模式
英文:

overwrite @Where JPA annotation

问题

我在预约方面遇到了一个问题。持久性由JPA控制,并且在一个实体上有一个名为@where的注释,该注释在该实体的任何地方都“失败”了0的值,对于在@where中指定的列,无论何时进行实体中。例如,如果选择一个ID,Hibernate将自动插入在@where中指定的列为0的地方。

问题是现在我在该列中有一个等于1的where子句,hibernate会覆盖我的where子句,并且只会带回具有0值的记录。

我的问题是是否有一种方法可以仅在我的查询中忽略此where子句?您将在下面输入的代码中进行。

谢谢!

SELECT 哔啦啦 哔啦啦

这里是我必须进行内连接的表

内连接
        minhatabela mtabela 
             outratabela.id=mtabela.id_outratabela 
            并且 (
                mtabela.coluna = 0 // 每当由于实体中的@where注释使用了此表时,此where会自动插入
            )

从这里开始

来自
    outratabela
        其中

outratabela.id=66666666 
        并且 minhatabela.coluna=1 

我的实体

@Entity @Table(name = "minhatabela") @Data @Builder @NoArgsConstructor
@AllArgsConstructor @Where(clause = "coluna = 0") 
// 这个注解
// 会覆盖,但我不能删除它,因为它在每个系统中都有用到,
// 我将不得不涉及多个地方。public class MinhaTabela {
// 
// ...........

是否有任何方法可以仅在我的条件中忽略此注解?

谢谢!

英文:

I have a problem with an appointment. A persistence is controlled with JPA and there is an annotation @where an entity that "fails" a value of 0 for that column anywhere it is made in that entity. If you are selecting an ID for example, hibernate will automatically be inserted where the column specified in @where is 0.

The problem is that now I have a where in that column where = 1 and hibertant overrides my where and bring only records with a value of 0.

My question is there any kind of ignoring this where only in my consultation? you will enter the code below.

Thank you!

SELECT blah blah blah

Here inner join with the table I have to do the inner join

inner join
        minhatabela mtabela 
            on outratabela.id=mtabela.id_outratabela 
            and (
                mtabela.coluna = 0 // This where automatically enters whenever this table is used due to the @where annotation in the entity
            )

from
    outratabela
        where

outratabela.id=66666666 
        and minhatabela.coluna=1 

My Entity

> @Entity @Table(name = "minhatabela") @Data @Builder @NoArgsConstructor
> @AllArgsConstructor @Where(clause = "coluna = 0") 
// This annotation
> overwrites, but I can't remove it because it is used in every system and
> I would have to touch several points. public class MinhaTabela {
> 
> ...........

Is there any way to ignore this annotation only in my criteria?

Thank you!

huangapple
  • 本文由 发表于 2020年5月5日 00:06:19
  • 转载请务必保留本文链接:https://java.coder-hub.com/61596562.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定