Ok, I'm rather new to Spring Boot and I'm currently facing a problem with attempting to successfully run the following Query towards my MySQL-Database in Postman without receiving a list of null-values:
@Query("SELECT user.id, user.email FROM ProjectUser user WHERE user.lastLogin IS NOT NULL AND user.userType = 'Test'") List<ProjectUser> test1(); User.id and user.email is of type bigint(20) and VARCHAR(255) in the database, and I suspect that it might be related to them not being declared as NVARCHAR, but I have not tried modifying this as I'm scared it will corrupt the database :P. However, I see that the conditioning works as the number of objects returned is correct, so I'm suspecting that the issue is mainly related to representing the values.
In comparison, the following NativeQuery works and returns non-null values in Postman:
@Query(value = "SELECT id, email FROM user WHERE last_login IS NOT NULL AND user_type = 'Test'", nativeQuery = true) List<ProjectUser> test1(); I was just wondering if anyone here might have an idea to how to fix this problem? I don't necessarily see why I should not go with the NativeQuery-solution when it works, but it is more of curiosity and understanding the problem.
@Query("SELECT user FROM ProjectUser user WHERE user.lastLogin IS NOT NULL AND user.userType = 'Test'")