Support for javax/jakarta.validation in entity views
Hello,
I am looking for a way to enable entity validation for entity view classes when used with Spring Data JPA. Not sure if I missed something but I can't find a way to get blaze repositories to validate the entities.
Is this supported?
Hi, can you please share more details? Usually, there are two types of validation:
- Validation on persistence (Hibernate configuration)
- Validation on request (Spring MVC)
Please show the repositories you are using as well as the invoking code and share the exact expectations.
I am talking about validation on persistence. Validation of request bodies is working as expected.
So in this case the email validation works fine as request validation but not when saving a view.
@EntityView(User::class)
@CreatableEntityView
interface InviteUserView {
@get:IdMapping
val id: UUID
@get:Email
var email: String
}
@Transactional
interface InviteUserViewRepository : EntityViewRepository<InviteUserView, UUID> {
fun save(user: InviteUserView): InviteUserView
}
@Service
class SomeUserService @Autowired constructor(
private val repository: InviteUserViewRepository,
) {
fun saveUser(user: InviteUserView): InviteUserView {
return repository.save(user)
}
}
The repositories are scanned via @EnableBlazeRepositories("....").
Ok, so validation of creatable/updatable entity views is currently not automatically done when an object is passed to some save method. I'll mark this as feature request then.
Ok, thanks!