I needed to load all the entities, mapping helped
@Entity
@Where(clause = "is_active = true")
data class Account(
@Column(unique = true, nullable = false)
var phone: String,
@Embedded
val name: Name,
@Column(nullable = false)
var password: String,
@ManyToOne(fetch = FetchType.EAGER)
var role: Role,
var isActive: Boolean
){
@Id
var id: Long = 0
@CreationTimestamp
var dateCreated: Timestamp? = null
@UpdateTimestamp
var dateUpdated: Timestamp? = null
}
Create the same entity and map it
@Entity
@Immutable
@Subselect("select * from account")
data class AccountWithRemove(
@Column(unique = true, nullable = false)
var phone: String,
@Embedded
val name: Name,
@Column(nullable = false)
var password: String,
@ManyToOne(fetch = FetchType.EAGER)
var role: Role,
var isActive: Boolean,
var code: Long?
) {
@Id
var id: Long = 0
@CreationTimestamp
var dateCreated: Timestamp? = null
@UpdateTimestamp
var dateUpdated: Timestamp? = null
}
This is how the request with the specification looks like. Search for regular and deleted accounts
from
( select
*
from
account ) accountwit0_
where
accountwit0_.is_active=true
or accountwit0_.is_active=false
And this is a normal findAll()
from
( select
*
from
account ) accountwit0_
Hibernate doesn't create a new table, we just create a new entity and map the one where we don't need the @Wnere annotation.
I removed some of the fields, but I think the meaning is clear