GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||
GeezerVison is showing github.com — Support for implicit conversion between java.time.LocalDate and java.time.LocalDateTime · Issue #3199 · mapstruct/mapstruct Closed Labels Milestone DescriptionExpected behaviorEither Actual behavior
The problem seems to be related to incorrect mapping sequence: LocalDateTime localDateTime = xmlGregorianCalendarToLocalDateTime( localDateToXmlGregorianCalendar( date ) ); Generated method Methods I'm talking about for reference: private static LocalDateTime xmlGregorianCalendarToLocalDateTime( XMLGregorianCalendar xcal ) { if ( xcal == null ) { return null; } if ( xcal.getYear() != DatatypeConstants.FIELD_UNDEFINED && xcal.getMonth() != DatatypeConstants.FIELD_UNDEFINED && xcal.getDay() != DatatypeConstants.FIELD_UNDEFINED && xcal.getHour() != DatatypeConstants.FIELD_UNDEFINED && xcal.getMinute() != DatatypeConstants.FIELD_UNDEFINED ) { //some mapping } return null; } private XMLGregorianCalendar localDateToXmlGregorianCalendar( LocalDate localDate ) { if ( localDate == null ) { return null; } return datatypeFactory.newXMLGregorianCalendarDate( localDate.getYear(), localDate.getMonthValue(), localDate.getDayOfMonth(), DatatypeConstants.FIELD_UNDEFINED ); } public XMLGregorianCalendar newXMLGregorianCalendarDate( final int year, final int month, final int day, final int timezone) { return newXMLGregorianCalendar( year, month, day, DatatypeConstants.FIELD_UNDEFINED, // hour DatatypeConstants.FIELD_UNDEFINED, // minute DatatypeConstants.FIELD_UNDEFINED, // second DatatypeConstants.FIELD_UNDEFINED, // millisecond timezone); } Steps to reproduce the problemDefine Mapper: @Mapper public interface IssueBelkinmikeMapper { IssueBelkinmikeMapper INSTANCE = Mappers.getMapper( IssueBelkinmikeMapper.class ); LocalDateTime map(LocalDate date); } Define Test: @WithClasses({ IssueBelkinmikeMapper.class }) @IssueKey("belkinmike") class IssueBelkinmikeMapperTest { @ProcessorTest void throwsException() { LocalDate source = LocalDate.of(2022, 2, 2); LocalDateTime target = IssueBelkinmikeMapper.INSTANCE.map(source); assertThat(target).isNotNull(); } } Test should pass or fail at mapper generation stage, but it is not IMHO: It should fail at generating such mapping, cause I met this problem mapping dtos: I had this classes class EntityDto { LocalDate dateFrom; } class Entity { LocalDate dateFrom; } interface MyMapper { EntityDto map(Entity e); } then dto field's type changed to LocalDateTime: class EntityDto { LocalDateTime dateFrom; } class Entity { LocalDate dateFrom; } interface MyMapper { EntityDto map(Entity e); } And I would expect mapping to fail and attract my attention to it, but it did not MapStruct Versionmain branch (commit id=a7ba12676d237957be0753076f436d7974c9f7f4) Reacted by Sirttas Activity
MetadataMetadataAssigneesLabelsTypeProjectsMilestoneRelationshipsDevelopmentIssue actions | ||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |