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

Expandable query parts size should be the same as parameters size + 1 #3233

Open
meriouma opened this issue Nov 17, 2024 · 4 comments
Open
Labels
type: bug Something isn't working

Comments

@meriouma
Copy link

Expected Behavior

Everything works as with micronaut-data 4.9.x

Actual Behaviour

I have this repository setup :

import io.micronaut.data.jdbc.annotation.JdbcRepository
import io.micronaut.data.model.Pageable
import io.micronaut.data.model.Slice
import io.micronaut.data.model.query.builder.sql.Dialect
import io.micronaut.data.repository.CrudRepository

@JdbcRepository(dialect = Dialect.MYSQL)
interface OutboxJdbcOperations : CrudRepository<OutboxEntryEntity, OutboxEntryId> {
    fun findAll(pageable: Pageable): Slice<OutboxEntryEntity>
}
@MappedEntity("\${application.datasource.table-prefix}rabbitmq_outbox")
data class OutboxEntryEntity(
    @field:Id
    @MappedProperty("id", type = DataType.LONG)
    val id: OutboxEntryId? = null,
    @MappedProperty("exchange", type = DataType.STRING)
    val exchange: String,
    @MappedProperty("topic", type = DataType.STRING)
    val topic: String,
    @MappedProperty("headers", type = DataType.JSON)
    val headers: Map<String, Any?>,
    @MappedProperty("body", type = DataType.STRING)
    val body: String,
)
data class OutboxEntryId(
    val value: Long,
) {
    override fun toString(): String {
        return "OutboxEntryId($value)"
    }
}

Calling the findAll method with a Pageable (e.g.: operations.findAll(Pageable.from(0, count))) throws the following :

java.lang.IllegalStateException: Expandable query parts size should be the same as parameters size + 1. 6 != 1 + 1 SELECT outbox_entry_entity_.`id`,outbox_entry_entity_.`exchange`,outbox_entry_entity_.`topic`,outbox_entry_entity_.`headers`,outbox_entry_entity_.`body` FROM `tester_rabbitmq_outbox` outbox_entry_entity_ [SELECT outbox_entry_entity_.`id`, outbox_entry_entity_.`exchange`, outbox_entry_entity_.`topic`, outbox_entry_entity_.`headers`, outbox_entry_entity_.`body` FROM `tester_rabbitmq_outbox` outbox_entry_entity_, ]
	at io.micronaut.data.runtime.operations.internal.sql.DefaultSqlStoredQuery.<init>(DefaultSqlStoredQuery.java:68)
	at io.micronaut.data.runtime.operations.internal.sql.AbstractSqlRepositoryOperations.decorate(AbstractSqlRepositoryOperations.java:189)
	at io.micronaut.data.runtime.intercept.AbstractQueryInterceptor.findStoreQuery(AbstractQueryInterceptor.java:245)
	at io.micronaut.data.runtime.intercept.AbstractQueryInterceptor.prepareQuery(AbstractQueryInterceptor.java:230)
	at io.micronaut.data.runtime.intercept.DefaultFindSliceInterceptor.intercept(DefaultFindSliceInterceptor.java:55)
	at io.micronaut.data.runtime.intercept.DataIntroductionAdvice.intercept(DataIntroductionAdvice.java:83)
	at io.micronaut.aop.chain.MethodInterceptorChain.proceed(MethodInterceptorChain.java:143)

Steps To Reproduce

No response

Environment Information

No response

Example Application

No response

Version

micronaut 4.7.0, micronaut-data 4.10.x

@meriouma meriouma changed the title Pageable : Expandable query parts size should be the same as parameters size + 1 Expandable query parts size should be the same as parameters size + 1 Nov 17, 2024
@radovanradic
Copy link
Contributor

Hello @meriouma,

I tried to reproduce issue but not reproducing it. Here is the example created based on your posted model and repo
mn-kotlin-jdbc-pageable.zip
with minor difference - I had to add converter for the id field, not sure how the save is working for you. But, it should not affect behavior with pageable. Please review this example and add what is missing to reproduce the issue.

Thanks

@dstepanov
Copy link
Contributor

Might be related to the property expression in the entity name

@meriouma
Copy link
Author

@dstepanov You're right, removing the expression in the entity name works. Was it working by accident and this is unsupported or a new bug?

@radovanradic radovanradic added the type: bug Something isn't working label Nov 19, 2024
@radovanradic
Copy link
Contributor

Looks like a bug in micronaut-data 4.10.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants