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

Using CustomMapper class from jar dependency don't work #47

Closed
Beuya opened this Issue Dec 2, 2014 · 4 comments

Comments

Projects
None yet
2 participants
@Beuya

Beuya commented Dec 2, 2014

We would to use a CustomMapper class declared in a common jar for several app. But when we declare this class in the mapper interface (@Mapper withCustom), the generated java source doesn't map the fields with the declared custom mapper. Note that the custom mapper is declared well as field in the generated class.

Thanks for your works

@slemesle

This comment has been minimized.

Show comment
Hide comment
@slemesle

slemesle Dec 2, 2014

Can you provide a sample code ?
I would also need the compiler output don't you have any warning reporting the custom mapper is never used.
This can occur, if Selma do not find any match for (in Type, out Type) pair in the bean properties it maps.

slemesle commented Dec 2, 2014

Can you provide a sample code ?
I would also need the compiler output don't you have any warning reporting the custom mapper is never used.
This can occur, if Selma do not find any match for (in Type, out Type) pair in the bean properties it maps.

@Beuya

This comment has been minimized.

Show comment
Hide comment
@Beuya

Beuya Dec 2, 2014

In a common jar named TestSelmaCommon, I have a custom type :

            public class DateBO {

                private String date;

                public DateBO(String date){
                    this.date = date;
                }

                public String getDate(){
                    return date;
                }
            }

and a custom mapper :

            public class CustomMapper {

                public DateBO dateStringToDateBO(String dateString) {
                    return new DateBO(dateString);
                }

            }

In another jar (my app) named TestSelmaApp (which depend on TestSelmaCommon), I have my objects to mapped

            public class TypeIn {

                private String attributDate;

                public String getAttributDate() {
                    return attributDate;
                }

                public void setAttributDate(String attributDate) {
                    this.attributDate = attributDate;
                }
            }


            public class TypeOut {

                private DateBO attributDate;

                public DateBO getAttributDate() {
                    return attributDate;
                }

                public void setAttributDate(DateBO attributDate) {
                    this.attributDate = attributDate;
                }
            }

and the mapper :

            @Mapper(withCustom=CustomMapper.class)
            public interface TestMapper {

                TypeOut toTypeOut(TypeIn in);
            }

When I compile TestSelmaApp, this error occurs :
TestMapper.java:[16,9] Failed to generate mapping method for type java.lang.String to test.selma.DateBO not supported on test.selma.mapper.TestMapper.toTypeBO(test.selma.type.TypeIn)

When I move the CustomMapper class to the TestSelmaApp, it's OK.

I compile with a jdk1.6 (IBM Websphere) and use Selma in v0.9

Beuya commented Dec 2, 2014

In a common jar named TestSelmaCommon, I have a custom type :

            public class DateBO {

                private String date;

                public DateBO(String date){
                    this.date = date;
                }

                public String getDate(){
                    return date;
                }
            }

and a custom mapper :

            public class CustomMapper {

                public DateBO dateStringToDateBO(String dateString) {
                    return new DateBO(dateString);
                }

            }

In another jar (my app) named TestSelmaApp (which depend on TestSelmaCommon), I have my objects to mapped

            public class TypeIn {

                private String attributDate;

                public String getAttributDate() {
                    return attributDate;
                }

                public void setAttributDate(String attributDate) {
                    this.attributDate = attributDate;
                }
            }


            public class TypeOut {

                private DateBO attributDate;

                public DateBO getAttributDate() {
                    return attributDate;
                }

                public void setAttributDate(DateBO attributDate) {
                    this.attributDate = attributDate;
                }
            }

and the mapper :

            @Mapper(withCustom=CustomMapper.class)
            public interface TestMapper {

                TypeOut toTypeOut(TypeIn in);
            }

When I compile TestSelmaApp, this error occurs :
TestMapper.java:[16,9] Failed to generate mapping method for type java.lang.String to test.selma.DateBO not supported on test.selma.mapper.TestMapper.toTypeBO(test.selma.type.TypeIn)

When I move the CustomMapper class to the TestSelmaApp, it's OK.

I compile with a jdk1.6 (IBM Websphere) and use Selma in v0.9

@slemesle slemesle added the bug label Dec 3, 2014

@slemesle slemesle added this to the 0.10 milestone Dec 3, 2014

@slemesle slemesle self-assigned this Dec 3, 2014

slemesle added a commit that referenced this issue Dec 3, 2014

@slemesle

This comment has been minimized.

Show comment
Hide comment
@slemesle

slemesle Dec 3, 2014

Thanks for the sample code it helped.
So there was a bad hashcode method in the InOutType class, causing the mapping registry to fail resolving some mappers like the custom mapper.

Could you try the fix in 0.10-SNAPSHOT latest build ?
see "Snapshot builds" in site documentation| to add the snapshot repsitory to your pom.xml.

slemesle commented Dec 3, 2014

Thanks for the sample code it helped.
So there was a bad hashcode method in the InOutType class, causing the mapping registry to fail resolving some mappers like the custom mapper.

Could you try the fix in 0.10-SNAPSHOT latest build ?
see "Snapshot builds" in site documentation| to add the snapshot repsitory to your pom.xml.

@Beuya

This comment has been minimized.

Show comment
Hide comment
@Beuya

Beuya Dec 4, 2014

It's works. Thanks for your quick fix!

Beuya commented Dec 4, 2014

It's works. Thanks for your quick fix!

@Beuya Beuya closed this Dec 4, 2014

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