quarkus-mybatis
quarkus-mybatis copied to clipboard
No constructor found in xxxbean matching [java.lang.Long, java.lang.Long, ....]
I had the same problem as this issue in native mode(jvm is fine) :issue This is supposed to be a reflex problem,when you use a bean to receive the result in mapper, this problem will come up.
and my log is:
Caused by: org.apache.ibatis.executor.ExecutorException: No constructor found in com.sensetime.jupiter.source.dto.BreakthroughSum matching [java.lang.Long, java.lang.Long]
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.lambda$createByConstructorSignature$1(DefaultResultSetHandler.java:705)
at java.util.Optional.orElseThrow(Optional.java:403)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.createByConstructorSignature(DefaultResultSetHandler.java:704)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.createResultObject(DefaultResultSetHandler.java:669)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.createResultObject(DefaultResultSetHandler.java:642)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:404)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForSimpleResultMap(DefaultResultSetHandler.java:361)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:335)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:308)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:201)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:65)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)
at java.lang.reflect.Method.invoke(Method.java:568)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:64)
at jdk.proxy4.$Proxy69.query(Unknown Source)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:81)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62)
at jdk.proxy4.$Proxy70.query(Unknown Source)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:151)
I try to add these classes in reflect-config.json,and it works . Is there any future restoration plan?
What did you add in reflect-config.json ?
mapper is :
@Select("select level,count(1) as num from t_breakthrough where deleted = 0 GROUP BY level ORDER BY level;")
@ResultType(BreakthroughSum.class)
List<BreakthroughSum> getBreakthroughCount();
and i add BreakthroughSum to reflect-config.json :
[
{
"name": "com.sensetime.jupiter.source.dto.BreakthroughSum",
"allDeclaredClasses": true,
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"allPublicClasses": true
}
]
I think we can use @RegisterForReflection here just like:
@Mapper
@RegisterForReflection(classNames = {"com.sensetime.jupiter.source.dto.BreakthroughSum"})
public class MyMapper {
@Select("select level,count(1) as num from t_breakthrough where deleted = 0 GROUP BY level ORDER BY level;")
@ResultType(BreakthroughSum.class)
List<BreakthroughSum> getBreakthroughCount();
}
Maybe we can do this in MyBatisProcessor to collect the annation @ResultType and register the class automatically. I need a further investigation.
About quarkus, I am very happy to learn a new annotation @RegisterForReflection 。It would be great if it could be done automatically