modelmapper / modelmapper

Intelligent object mapping
http://modelmapper.org
Apache License 2.0
2.27k stars 347 forks source link

Cannot map to java.sql.Date #519

Open promoscow opened 4 years ago

promoscow commented 4 years ago

I have some classes, generated with jooq-generator. Some fields are java.sql.Date. I write something like this:

jooqMapper.createTypeMap(Profile.class, ProfilesRecord.class)
            .addMappings(m -> {
                m.skip(ProfilesRecord::setId);
                m.skip(ProfilesRecord::setCreated);
                m.skip(ProfilesRecord::setUpdated);
                m.skip(ProfilesRecord::setPassportIssueDate);
                m.skip(ProfilesRecord::setBirthDate);
            }).setPostConverter(toRecordConverter());

Than, I initialize this fields in toRecordConverter(). But when I try to run it, I receive:

Failed to instantiate instance of destination java.sql.Date. Ensure that java.sql.Date has a non-private no-argument constructor.
Caused by: java.lang.NoSuchMethodException: java.sql.Date.<init>()

Okay, java.sql.Date have no no-argument constructor. Skipping java.sql.Date fields did not helps. Have I any ways to avoid this exception without changing field types?

chhsiao90 commented 3 years ago

Sorry for the lately reply, I can't reproduce the java.sql.Date issue now, can you try to update modelmapper and check if issue still reproducible? Thanks.