Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Springboot 3.0 : Hiberanate/JPA 6 validation fail

I am having a method like this

 @Modifying( clearAutomatically = true )
    @Query( "update versioned LookupMaster set state =  'PUBLISHED' , value = newValue, newValue = null, updatedDate = current_timestamp where ( name = :tableName and state = 'MODIFIED')" )
    void commitLookupTableChanges( String tableName );

It was working before springboot 3 upgrade. After springboot upgrade to version 3.0.2 facing validation error like below.

Caused by: java.lang.IllegalArgumentException: org.hibernate.query.SemanticException: The assignment expression type [java.lang.String] did not match the assignment path type [com.nokia.nsw.lookuptable.model.RowState] for the path [alias_2093546827.state] [update versioned LookupMaster set state =  'PUBLISHED' , value = newValue, newValue = null, updatedDate = current_timestamp where ( name = :tableName and state = 'MODIFIED')]

Code for Rowstate :

public enum RowState {
    MODIFIED, DELETED, PUBLISHED
}
like image 376
user3080775 Avatar asked Oct 31 '25 12:10

user3080775


1 Answers

Remove the single quotes around PUBLISHED and MODIFIED. That is, change the query to:

update versioned LookupMaster set state = PUBLISHED, value = newValue, newValue = null, updatedDate = current_timestamp where ( name = :tableName and state = MODIFIED)

UPDATE

So that is a bug https://hibernate.atlassian.net/browse/HHH-16170 and we will get it fixed.

As a temporary workaround, you can write the query using a full-qualified name for the enum value:

update versioned LookupMaster set state = full.package.name.RowState.PUBLISHED, value = newValue, newValue = null, updatedDate = current_timestamp where ( name = :tableName and state = MODIFIED)
like image 109
Gavin King Avatar answered Nov 02 '25 03:11

Gavin King



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!