Skip to content

Crud repository query methods are not working with List<Enum> as a parameter. #1855

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

Closed
jakov222 opened this issue Oct 23, 2023 · 6 comments
Closed
Labels
status: waiting-for-triage An issue we've not yet triaged type: bug A general bug

Comments

@jakov222
Copy link

jakov222 commented Oct 23, 2023

Hello,
I am trying to write a method which accepts List containing enum as a parameter in an interface extending ListCrudRepository<T, UUID>

T findByEnumType(List<EnumType> enums)

however, in the result exception is thrown:

Caused by: com.couchbase.client.core.error.InvalidArgumentException: Unsupported type for JSON value: class com.xxx.EnumType
	at com.couchbase.client.core.error.InvalidArgumentException.fromMessage(InvalidArgumentException.java:28)
	at com.couchbase.client.java.json.JsonValue.coerce(JsonValue.java:94)
	at com.couchbase.client.java.json.JsonArray.add(JsonArray.java:178)

@mikereiche
Copy link
Collaborator

mikereiche commented Oct 23, 2023

Can you please look at the solution in #1837 ?

If that does not help, can you show your application and where it fails?

@jakov222
Copy link
Author

I tested on 5.1.5 and it still doesn't work. I am not overriding any couchbase configuration. I am only having single ListCrudRepository bean, where all methods are working expect the one mentioned above. I will to provide mini project reproducing it in the coming days

@jakov222
Copy link
Author

jakov222 commented Oct 24, 2023

There's a bigger stacktrace:

Caused by: com.couchbase.client.core.error.InvalidArgumentException: Unsupported type for JSON value: class com.EventType
	at com.couchbase.client.core.error.InvalidArgumentException.fromMessage(InvalidArgumentException.java:28)
	at com.couchbase.client.java.json.JsonValue.coerce(JsonValue.java:94)
	at com.couchbase.client.java.json.JsonArray.add(JsonArray.java:178)
	at org.springframework.data.couchbase.core.query.QueryCriteria.addAsCollection(QueryCriteria.java:650)
	at org.springframework.data.couchbase.core.query.QueryCriteria.maybeWrapValue(QueryCriteria.java:598)
	at org.springframework.data.couchbase.core.query.QueryCriteria.exportSingle(QueryCriteria.java:565)
	at org.springframework.data.couchbase.core.query.QueryCriteria.export(QueryCriteria.java:526)
	at org.springframework.data.couchbase.core.query.Query.appendWhere(Query.java:279)
	at org.springframework.data.couchbase.core.query.Query.toN1qlSelectString(Query.java:359)
	at org.springframework.data.couchbase.core.ReactiveFindByQueryOperationSupport$ReactiveFindByQuerySupport.assembleEntityQuery(ReactiveFindByQueryOperationSupport.java:281)
	at org.springframework.data.couchbase.core.ReactiveFindByQueryOperationSupport$ReactiveFindByQuerySupport.all(ReactiveFindByQueryOperationSupport.java:182)
	at org.springframework.data.couchbase.core.ExecutableFindByQueryOperationSupport$ExecutableFindByQuerySupport.all(ExecutableFindByQueryOperationSupport.java:95)
	at org.springframework.data.couchbase.repository.query.AbstractCouchbaseQuery.lambda$getExecutionToWrap$1(AbstractCouchbaseQuery.java:124)
	at org.springframework.data.couchbase.repository.query.CouchbaseQueryExecution$ResultProcessingExecution.execute(CouchbaseQueryExecution.java:84)
	at org.springframework.data.couchbase.repository.query.AbstractCouchbaseQuery.doExecute(AbstractCouchbaseQuery.java:93)
	at org.springframework.data.couchbase.repository.query.AbstractCouchbaseQueryBase.execute(AbstractCouchbaseQueryBase.java:132)
	at org.springframework.data.couchbase.repository.query.AbstractCouchbaseQueryBase.execute(AbstractCouchbaseQueryBase.java:113)
	at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:136)
	at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:120)
	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:164)
	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:143)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
	at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:72)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
	at org.springframework.data.couchbase.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:145)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:244)
	at com.findByEventTypes(Unknown Source)
	at com.findConfigsByEventType(XXXREPOsitory.java:32)

@mikereiche
Copy link
Collaborator

mikereiche commented Oct 24, 2023

Yes. I never actually fixed it. I just provided a work-around. Sorry for sending you down that path.

I am not overriding any couchbase configuration.

That's the issue. Since you don't override it, you get one provided for you ... the couchbaseCustomConversions created in CouchbaseDataConfiguration does not have the Enum converters (I'll need to work with spring-boot-autoconfigure to fix that). The work-around in #1837 is to have the @configuration class extend AbstractCouchbaseConfiguration (see the last post in #1837).

@jakov222
Copy link
Author

Alright, thank you! Is there a chance that the autoconfiguration fix will come anywhere soon?

@mikereiche
Copy link
Collaborator

mikereiche commented Oct 25, 2023

The fix is merged into main. It will be in the next release which is scheduled for November 17. It will already be in the latest 5.2 SNAPSHOT. I'll merge it into the 5.1 and 5.0 branches to day and it will be in those SNAPSHOTS tomorrow. There is information in the doc how to get the SNAPSHOTs @jakubszybisty . I've used #1837 as the main issue for this, so you'll find more details there.

@mikereiche mikereiche added this to the 5.2 GA (2023.1.0) milestone Oct 25, 2023
@mikereiche mikereiche added the type: bug A general bug label Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants