micronaut-data
micronaut-data copied to clipboard
Repository update is not working with @Where on repository and @JoinTable in entity
Expected Behavior
Calling the update method of a repository with @Where and of an entity containing a @JoinTable mapping should update this entity accordingly. In version 3.1.2 it worked fine.
Actual Behaviour
The application thows following exception:
java.lang.IllegalArgumentException: org.hibernate.QueryException: Components currently not assignable in update statements
Steps To Reproduce
Unfortunately, I could not reproduce the scenario in isolation, because of other issues regarding the test project-setup.
Basically I have an DTO which looks like this:
@Entity
@Table(name="posts")
data class PostDTO {
@Id
val id: UUID,
val title: String,
val deleted: Boolean,
@OneToOne(cascade = [CascadeType.ALL])
@JoinTable(
name = "post_xyz",
joinColumns = [JoinColumn(name = "post_id")],
inverseJoinColumns = [
JoinColumn(name = "xyz_id", referencedColumnName = "id"),
JoinColumn(name = "tenant", referencedColumnName = "tenant"),
],
)
val xyz: XyzDTO?,
}
The repository looks like this:
@Repository
@JoinSpecifications(
Join(value = "xyz", type = Join.Type.LEFT_FETCH)
)
@Where("postDTO_.deleted = false")
interface PostRepository : ReactiveStreamsCrudRepository<PostDTO, UUID> {
fun update(post: PostDTO): Mono<PostDTO>
//...
}
If needed I will try to provide a working sample project, but maybe someone can already see the issue. Let me know.
Environment Information
- JDK: 17
Example Application
No response
Version
3.2.*
It would be the best to provide a sample project, I don't see anything strange, maybe if you post full exception and generated query.
@jbtippelt I can replicate it now, it looks like after we fixed generating an update with a query that includes the where statement it started to generate incompatible JPQL. We would need to add something like @NoWhere or @JpaUpdate/@JpaMerge to only call the underlying method.
Just ran into this bug in 3.4 -- skimmed the release notes but it seems like there is no fix for it yet. Is the only workaround removing @Where annotation?