Marius K (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZTBlYmExZTkw...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16216?atlOrigin=eyJpIjoiZTBlYm...
) HHH-16216 (
https://hibernate.atlassian.net/browse/HHH-16216?atlOrigin=eyJpIjoiZTBlYm...
) @Query creates additional not null checks for Sybase (
https://hibernate.atlassian.net/browse/HHH-16216?atlOrigin=eyJpIjoiZTBlYm...
)
Change By: Marius K (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3...
)
I upgraded from Spring Boot 2.7 to 3.0, hence from Hibernate 5 to Hibernate 6
Unfortunately the {{@Query}} annotations in a {{JpaRepository}} suddenly add {{not null}}
checks for all columns using Sybase.
It works fine with h2
{noformat}@Entity
@Table(name = "MY_USER")
@Getter
@Setter
@EqualsAndHashCode
public class MyUser {
@Id
@Column(name = "MY_USER_ID", unique = true, nullable = false)
private Integer myUserId;
@Column(name = "FIRSTNAME")
private String firstname;
@Column(name = "LASTNAME")
private boolean lastname;
}{noformat}
and
{noformat}public interface MyUserRepository extends JpaRepository<MyUser, Integer>
{
@Query("select r from MyUser r where r.firstname = :firstname and r.lastname =
:lastname")
List<MyUser> getUser(@Param("firstname") String firstname,
@Param("lastname") String lastname);
}{noformat}
results in the query
{{select m1_0.my_user_id,m1_0.firstname,m1_0.lastname from my_user m1_0 where
m1_0.firstname=? and m1_0.lastname=?}}
which is obviously fine.
But when I switch to Sybase
{noformat}spring.datasource.url=xxx
spring.datasource.username=xxx
spring.datasource.password=xxx
spring.datasource.driver-class-name=com.sybase.jdbc4.jdbc.SybDriver
spring.jpa.database-platform=org.hibernate.dialect.SybaseASEDialect{noformat}
{noformat}<dependency>
<groupId>com.sybase</groupId>
<artifactId>jconn4</artifactId>
</dependency>{noformat}
the query is
{{select m1_0.my_user_id,m1_0.firstname,m1_0.lastname from my_user m1_0 where
m1_0.firstname=? and m1_0.firstname is not null and m1_0.lastname=? and m1_0.lastname is
not null}}
with additional null checks. This breaks my code as it is no longer possible to pass null
to the parameters in the {{getUser}}` method.
It worked properly with Hibernate 5.6.14.
(
https://hibernate.atlassian.net/browse/HHH-16216#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16216#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100216- sha1:64a4cf6 )