'Override @Where clause in hibernate for another column in the same entity
I have an entity class with a where condition that pulls the records with ACTIVE = true flag. I have an additional column which is referring to the same class and i want to pull ACTIVE = true or ACTIVE = false records during query execution. Is there a way to override entity's @Where clause when calling the "PARENT_INSTANCE_ID" records?
@Entity
@Table(name = "MY_TABLE")
@Where(clause = "ACTIVE = true")
public class MyTable {
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "INSTANCE_ID")
private Long id;
@ManyToOne(fetch = LAZY)
@JoinColumn(name = "PARENT_INSTANCE_ID")
private MyTable parent;
.....
.....
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
