0

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!

Mussum
  • 21
  • 1
  • 10
  • Here is a similar answer.[answer](https://stackoverflow.com/questions/24659984/hibernate-how-to-ignore-where-annotation). One solution is to used native query instead. – Mohd Waseem May 04 '20 at 16:53
  • Does this answer your question? [Ignore Hibernate @Where annotation](https://stackoverflow.com/questions/2311125/ignore-hibernate-where-annotation) – areus May 04 '20 at 17:03
  • Thanks friends, I had to do the native query – Mussum Jun 02 '20 at 16:40

0 Answers0