Open GoogleCodeExporter opened 8 years ago
A fix has been applied to the latest master.
With the fix in place, there's a slight adjustment required to make this work:
mapperFactory.classMap(Person1.class, Person2.class)
.fieldAToB("firstname", "fn")
.fieldBToA("forename","firstname")
.register();
Original comment by matt.deb...@gmail.com
on 28 Oct 2013 at 4:20
I think I spotted a similar issue in Orkia 1.4.4.
My classes are:
public class A {
public A(String firstname) {
}
}
public class B {
public A(String fn) {
}
}
At first I did not have classmap and as expected no automatic mapping could be
performed. Which resulted in the following stacktrace:
Caused by: java.lang.NullPointerException
at ma.glasnost.orika.impl.generator.ObjectFactoryGenerator.addSourceClassConstructor(ObjectFactoryGenerator.java:168)
at ma.glasnost.orika.impl.generator.ObjectFactoryGenerator.addCreateMethod(ObjectFactoryGenerator.java:123)
at ma.glasnost.orika.impl.generator.ObjectFactoryGenerator.build(ObjectFactoryGenerator.java:94)
With the following mapping, the mapping works (I only needed one way):
mapperFactory.classMap(A.class, B.class)
.field("firstname", "fn")
.register();
Exception is caused by the following statement in ObjectFactoryGenerator (line
168):
if (properties.size() != constructorArguments.length) {
throw new MappingException("While attempting to generate ObjectFactory using constructor '" + constructor
+ "', an automatic mapping of the source type ('" + sourceType
+ "') to this constructor call could not be determined. Please "
+ "register a custom ObjectFactory implementation which is able to create an instance of '" + destinationType
+ "' from an instance of '" + sourceType + "'.");
}
The constructorArguments is null and thus the .length causes the exception,
instead of real exception to be thrown.
Original comment by villg...@gmail.com
on 30 Mar 2014 at 7:01
Original issue reported on code.google.com by
maxim.mo...@googlemail.com
on 14 Oct 2013 at 6:58Attachments: