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

Confusing error messages, nesting levels not considered. #1150

Closed
sjaakd opened this Issue Mar 22, 2017 · 6 comments

Comments

Projects
None yet
2 participants
@sjaakd
Contributor

sjaakd commented Mar 22, 2017

public class MyDate {

    private Date date;

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

}
public class Entity {

    private MyDate date;

    public MyDate getDate() {
        return date;
    }

    public void setDate(MyDate date) {
        this.date = date;
    }
    
}
public class Dto {

    private Date date;

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

}
@Mapper
public interface MyMapper {

    MyMapper INSTANCE = Mappers.getMapper( MyMapper.class );

    Entity map( Dto dto);

}

Leads to error message:

ERROR MyMapper.java:30 Can't map property "int date" to "java.util.Date date". Consider to declare/implement a mapping method: "java.util.Date map(int value)".

Took me a while to figure out that MapStruct actually tries to map the deprecated getDate() method the Java Date class..

The errror should have been:

ERROR MyMapper.java:30 Can't map property "int date.date" to "java.util.Date date.date". Consider to declare/implement a mapping method: "java.util.Date map(int value)".

@filiphr

This comment has been minimized.

Show comment
Hide comment
@filiphr

filiphr Mar 22, 2017

Member

Maybe we shouldn't be trying to forge mappings for objects that we have conversions (or objects in the Java package)?

Member

filiphr commented Mar 22, 2017

Maybe we shouldn't be trying to forge mappings for objects that we have conversions (or objects in the Java package)?

@sjaakd

This comment has been minimized.

Show comment
Hide comment
@sjaakd

sjaakd Mar 22, 2017

Contributor

Maybe we shouldn't be trying to forge mappings for objects that we have conversions (or objects in the Java package)?

?? We don't have a conversion from Date to MyDate..

The problem is that MapStruct maps all stuff and it gives no clue on which nesting level the problem is.

Let alone that we probably should exclude deprecated marked getters / setters and perhaps even have a means to indicate that MapStruct should ignore getters / setters on the DTO themselves.. (e.g. MyDate).

Contributor

sjaakd commented Mar 22, 2017

Maybe we shouldn't be trying to forge mappings for objects that we have conversions (or objects in the Java package)?

?? We don't have a conversion from Date to MyDate..

The problem is that MapStruct maps all stuff and it gives no clue on which nesting level the problem is.

Let alone that we probably should exclude deprecated marked getters / setters and perhaps even have a means to indicate that MapStruct should ignore getters / setters on the DTO themselves.. (e.g. MyDate).

@sjaakd

This comment has been minimized.

Show comment
Hide comment
@sjaakd

sjaakd Mar 22, 2017

Contributor

I'll issue some separate issues for that.. See #1151 and #1152

Contributor

sjaakd commented Mar 22, 2017

I'll issue some separate issues for that.. See #1151 and #1152

@filiphr

This comment has been minimized.

Show comment
Hide comment
@filiphr

filiphr Mar 22, 2017

Member

?? We don't have a conversion from Date to MyDate..

What I meant is that we have a conversion to create a Date, so we shouldn't go into Date during forging. I think that we can at least block recursive calls into the objects in the java package.

Member

filiphr commented Mar 22, 2017

?? We don't have a conversion from Date to MyDate..

What I meant is that we have a conversion to create a Date, so we shouldn't go into Date during forging. I think that we can at least block recursive calls into the objects in the java package.

@sjaakd

This comment has been minimized.

Show comment
Hide comment
@sjaakd

sjaakd Mar 23, 2017

Contributor
Contributor

sjaakd commented Mar 23, 2017

@filiphr

This comment has been minimized.

Show comment
Hide comment
@filiphr

filiphr Mar 23, 2017

Member

You are right this is more about the error. I created #1154 for that.

Member

filiphr commented Mar 23, 2017

You are right this is more about the error. I created #1154 for that.

@filiphr filiphr added this to the 1.2.0.Beta3 milestone Apr 21, 2017

@filiphr filiphr modified the milestones: 1.2.0.CR1, 1.2.0.Beta3 May 17, 2017

@filiphr filiphr self-assigned this Jun 28, 2017

filiphr added a commit to filiphr/mapstruct that referenced this issue Jun 28, 2017

@filiphr filiphr closed this in #1233 Jun 29, 2017

filiphr added a commit that referenced this issue Jun 29, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment