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

No constructor found in xxxbean matching [java.lang.Long, java.lang.Long, ....] #234

Open
daice3 opened this issue Oct 25, 2022 · 4 comments

Comments

@daice3
Copy link

daice3 commented Oct 25, 2022

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?

@zhfeng
Copy link
Collaborator

zhfeng commented Oct 25, 2022

What did you add in reflect-config.json ?

@daice3
Copy link
Author

daice3 commented Oct 25, 2022

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
  }
]

@zhfeng
Copy link
Collaborator

zhfeng commented Oct 26, 2022

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.

@daice3
Copy link
Author

daice3 commented Oct 27, 2022

About quarkus, I am very happy to learn a new annotation @RegisterForReflection 。It would be great if it could be done automatically

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