Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting java.lang.String cannot be cast to java.lang.Long exception #1949

Open
himanshumps opened this issue Jul 10, 2024 · 1 comment
Open
Assignees
Labels
type: regression A regression from a previous release

Comments

@himanshumps
Copy link

I am getting this exception (java.lang.String cannot be cast to java.lang.Long) when I have the version field declared as String and annotated with org.springframework.data.annotation.Version

@Version
private String version;
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long
02:20:35,571 INFO [stdout] (membershipChangeScheduler_Worker-2) at org.springframework.data.couchbase.repository.support.SimpleCouchbaseRepository.save(SimpleCouchbaseRepository.java:82) ~[spring-data-couchbase-4.4.0.jar:4.4.0]

The way the version field is being type casted has changed from spring-data-couchbase 3.2.x to 4.4.x in the save method (and probably other places as well which I might not be aware of)

4.4.x series: spring-data-couchbase/src/main/java/org/springframework/data/couchbase/repository/support/SimpleCouchbaseRepository.java at 149473cf83b48de6225b1f33cfd92a724da90a51 · spring-projects/spring-data-couchbase · GitHub

3.2.x series: spring-data-couchbase/src/main/java/org/springframework/data/couchbase/core/CouchbaseTemplate.java at 2efdf39ede45c72dca2f3472b5b23a7723fe87a2 · spring-projects/spring-data-couchbase · GitHub

Is there something we can do to help us migrate from 3.x to 4.x by avoiding this error.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 10, 2024
@mikereiche mikereiche added type: regression A regression from a previous release and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 10, 2024
@mikereiche
Copy link
Collaborator

I can look into fixing this in 5.x. Really, you should be migrating to 5.x if possible as it is the latest.

Is there something we can do to help us migrate from 3.x to 4.x by avoiding this error.

You can change String version to Long version

@mikereiche mikereiche self-assigned this Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

3 participants