You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way to force the mapper to use setters to populate a POJO? When my POJO has overloaded constructors the mappers expects an exact constructor matching the arguments with the columns in the SELECT clause. For instance,
class MyPojo {
private Long id;
private String name;
// No constructor
}
Note that MyPojo has default (no-arg) constructor only.
But in my case MyPojo is a legacy class and comes with a whole bunch of constructors:
class MyPojo {
private Long id;
private String name;
public MyPojo(Long id) {
this.id = id;
}
}
Note the Pojo now has an overloaded constructor. This causes the mapper to not work with the same query. I get the following error:
Could not find eligible property for 'name' on class com.bla.bla.MyPojo
It is apparent that the mapper is trying to look for a constructor with arguments matching the columns in the SELECT clause. I don't want to add overloaded constructors (the SELECT column list is huge). It'd be nice to force the mapper to call the setters regardless.
The text was updated successfully, but these errors were encountered:
there is some heuristics to find an injection point. If there is a setter it should be able to use it.
I would need a reproducer to see where the problem is.
Is there a way to force the mapper to use setters to populate a POJO? When my POJO has overloaded constructors the mappers expects an exact constructor matching the arguments with the columns in the SELECT clause. For instance,
Note that MyPojo has default (no-arg) constructor only.
The above works fine.
But in my case MyPojo is a legacy class and comes with a whole bunch of constructors:
Note the Pojo now has an overloaded constructor. This causes the mapper to not work with the same query. I get the following error:
It is apparent that the mapper is trying to look for a constructor with arguments matching the columns in the SELECT clause. I don't want to add overloaded constructors (the SELECT column list is huge). It'd be nice to force the mapper to call the setters regardless.
The text was updated successfully, but these errors were encountered: