Hello,
I am using the CurrentTenantIdentifierResolver to achieve multitenancy. My Entities/Tables have a @TenantId field/column.
In a JPA repository I would like to set a status of multiple Entites to true/false.
The repository function is the following:
@Modifying
@Query("UPDATE TriggerDAO t SET t.enabled = :status WHERE t.triggerId IN :triggerIds")
void updateTriggerStatus(boolean status, List<UUID> triggerIds);
When executing the update, the following SQL is printed:
update Triggers set enabled=? where triggerId in (?) and td1_0.fkTenantId = ?
The tenant id is automatically appended, however the table alias td1_0 is not set and therefore results in an error:
INVALID_ARGUMENT: Unrecognized name: td1_0 [at 1:62]
...set enabled=@p1 where triggerId in (@p2) and td1_0.fkTenantId = @p3
Using dependency:
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.6.11.Final</version>
</dependency>
My work around would be to use a native query (but then I have to set the tenant id manually). Is there an option to keep using HQL?