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

Unable to return byte[] from a JDBC repository interface #3075

Open
mikehearn opened this issue Aug 19, 2024 · 1 comment
Open

Unable to return byte[] from a JDBC repository interface #3075

mikehearn opened this issue Aug 19, 2024 · 1 comment

Comments

@mikehearn
Copy link

Expected Behavior

record MyEntity(@Id String id, @Nullable byte[] bytes) {}

@JdbcRepository(dialect = Dialect.H2)
public interface TaskRepository extends CrudRepository<TaskEntity, String> {
    byte[] getBytes(@Id String id);
}

Calling getBytes should work.

Actual Behaviour

Cannot convert type [class [B] with value [[B@4e68ed53] to target type: class java.lang.Byte. Consider defining a TypeConverter bean to handle this case.
io.micronaut.data.exceptions.DataAccessException: Cannot convert type [class [B] with value [[B@4e68ed53] to target type: class java.lang.Byte. Consider defining a TypeConverter bean to handle this case.
	at io.micronaut.data.runtime.mapper.ResultReader.lambda$convertRequired$0(ResultReader.java:51)
	at java.base/java.util.Optional.orElseThrow(Optional.java:403)
	at io.micronaut.data.runtime.mapper.ResultReader.convertRequired(ResultReader.java:50)
	at io.micronaut.data.runtime.operations.internal.sql.AbstractSqlRepositoryOperations$3.map(AbstractSqlRepositoryOperations.java:773)
	at io.micronaut.data.jdbc.operations.DefaultJdbcRepositoryOperations.findOne(DefaultJdbcRepositoryOperations.java:345)
	at io.micronaut.data.jdbc.operations.DefaultJdbcRepositoryOperations.lambda$findOne$0(DefaultJdbcRepositoryOperations.java:324)
	at io.micronaut.data.jdbc.operations.DefaultJdbcRepositoryOperations.lambda$executeRead$21(DefaultJdbcRepositoryOperations.java:763)
	at io.micronaut.data.connection.support.AbstractConnectionOperations.executeWithNewConnection(AbstractConnectionOperations.java:143)
	at io.micronaut.data.connection.support.AbstractConnectionOperations.execute(AbstractConnectionOperations.java:90)
	at io.micronaut.data.connection.ConnectionOperations.executeRead(ConnectionOperations.java:71)
	at io.micronaut.data.jdbc.operations.DefaultJdbcRepositoryOperations.executeRead(DefaultJdbcRepositoryOperations.java:760)
	at io.micronaut.data.jdbc.operations.DefaultJdbcRepositoryOperations.findOne(DefaultJdbcRepositoryOperations.java:324)
	at io.micronaut.data.runtime.intercept.DefaultFindOneInterceptor.intercept(DefaultFindOneInterceptor.java:45)
	at io.micronaut.data.runtime.intercept.DataIntroductionAdvice.intercept(DataIntroductionAdvice.java:83)
	at io.micronaut.aop.chain.MethodInterceptorChain.proceed(MethodInterceptorChain.java:138)

Steps To Reproduce

No response

Environment Information

No response

Example Application

No response

Version

4.7.1

@dstepanov
Copy link
Contributor

Please create a sample app, it's not enought information. How schema is generated, how bytes are stored etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants