convert java.util.ArrayList to java.util.List. Problem

5 488 vues
Passer au premier message non lu

J-23

non lue,
15 nov. 2016, 15 h 03 min 43 s2016-11-15
à modelmapper
Hello, I am new to ModelMapper.

I have a Hibernate mapping classes:

/**
 * Users generated by hbm2java
 */

@Entity
@Table(name = "USERS")
public class Users implements java.io.Serializable {

   
private Long idUsers;
   
private String isoLanguageDefault;
   
private String login;
   
private String password;
   
private Date lastLogged;
   
private Set installations = new HashSet(0);

   
public Users() {
   
}

   
public Users(String isoLanguageDefault, String login, String password) {
       
this.isoLanguageDefault = isoLanguageDefault;
       
this.login = login;
       
this.password = password;
   
}

   
public Users(String isoLanguageDefault, String login, String password, Date lastLogged, Set installations) {
       
this.isoLanguageDefault = isoLanguageDefault;
       
this.login = login;
       
this.password = password;
       
this.lastLogged = lastLogged;
       
this.installations = installations;
   
}

   
@Id
   
@GeneratedValue(strategy = IDENTITY)

   
@Column(name = "ID_USERS", unique = true, nullable = false)
   
public Long getIdUsers() {
       
return this.idUsers;
   
}

   
public void setIdUsers(Long idUsers) {
       
this.idUsers = idUsers;
   
}

   
@Column(name = "ISO_LANGUAGE_DEFAULT", nullable = false, length = 2)
   
public String getIsoLanguageDefault() {
       
return this.isoLanguageDefault;
   
}

   
public void setIsoLanguageDefault(String isoLanguageDefault) {
       
this.isoLanguageDefault = isoLanguageDefault;
   
}

   
@Column(name = "LOGIN", nullable = false, length = 10)
   
public String getLogin() {
       
return this.login;
   
}

   
public void setLogin(String login) {
       
this.login = login;
   
}

   
@Column(name = "PASSWORD", nullable = false, length = 10)
   
public String getPassword() {
       
return this.password;
   
}

   
public void setPassword(String password) {
       
this.password = password;
   
}

   
@Temporal(TemporalType.TIMESTAMP)
   
@Column(name = "LAST_LOGGED", length = 19)
   
public Date getLastLogged() {
       
return this.lastLogged;
   
}

   
public void setLastLogged(Date lastLogged) {
       
this.lastLogged = lastLogged;
   
}

   
@OneToMany(fetch = FetchType.LAZY, mappedBy = "users")
   
public Set getInstallations() {
       
return this.installations;
   
}

   
public void setInstallations(Set installations) {
       
this.installations = installations;
   
}

}

@Entity
@Table(name = "INSTALLATION")
public class Installation implements java.io.Serializable {

   
private Long idInstallation;
   
private Users users;
   
private String name;
   
private String description;

   
public Installation() {
   
}

   
public Installation(Users users) {
       
this.users = users;
   
}

   
public Installation(Users users, String name, String description) {
       
this.users = users;
       
this.name = name;
       
this.description = description;
   
}

   
@Id
   
@GeneratedValue(strategy = IDENTITY)

   
@Column(name = "ID_INSTALLATION", unique = true, nullable = false)
   
public Long getIdInstallation() {
       
return this.idInstallation;
   
}

   
public void setIdInstallation(Long idInstallation) {
       
this.idInstallation = idInstallation;
   
}

   
@ManyToOne(fetch = FetchType.LAZY)
   
@JoinColumn(name = "ID_USERS", nullable = false)
   
public Users getUsers() {
       
return this.users;
   
}

   
public void setUsers(Users users) {
       
this.users = users;
   
}

   
@Column(name = "NAME", length = 30)
   
public String getName() {
       
return this.name;
   
}

   
public void setName(String name) {
       
this.name = name;
   
}

   
@Column(name = "DESCRIPTION")
   
public String getDescription() {
       
return this.description;
   
}

   
public void setDescription(String description) {
       
this.description = description;
   
}

}


And their counterparts DTO:

public class UsersDTO implements Serializable {

   
/**
     *
     */

   
private static final long serialVersionUID = -1775553059834216966L;
   
private Long idUsers;
   
private String isoLanguageDefault;
   
private String login;
   
private String password;
   
private Date lastLogged;
   
private InstallationDTO installations;
   
   
public UsersDTO() {
   
}

   
public UsersDTO(String isoLanguageDefault, String login, String password) {
       
this.isoLanguageDefault = isoLanguageDefault;
       
this.login = login;
       
this.password = password;
   
}

   
public UsersDTO(String isoLanguageDefault, String login, String password, Date lastLogged, InstallationDTO installations) {
       
this.isoLanguageDefault = isoLanguageDefault;
       
this.login = login;
       
this.password = password;
       
this.lastLogged = lastLogged;
       
this.installations = installations;
   
}

   
public Long getIdUsers() {
       
return idUsers;
   
}

   
public void setIdUsers(Long idUsers) {
       
this.idUsers = idUsers;
   
}

   
public String getIsoLanguageDefault() {
       
return isoLanguageDefault;
   
}

   
public void setIsoLanguageDefault(String isoLanguageDefault) {
       
this.isoLanguageDefault = isoLanguageDefault;
   
}

   
public String getLogin() {
       
return login;
   
}

   
public void setLogin(String login) {
       
this.login = login;
   
}

   
public String getPassword() {
       
return password;
   
}

   
public void setPassword(String password) {
       
this.password = password;
   
}

   
public Date getLastLogged() {
       
return lastLogged;
   
}

   
public void setLastLogged(Date lastLogged) {
       
this.lastLogged = lastLogged;
   
}

   
public InstallationDTO getInstallation() {
       
return installations;
   
}

   
public void setInstallation(InstallationDTO installations) {
       
this.installations = installations;
   
}
}


public class InstallationDTO implements Serializable {

   
/**
     *
     */

   
private static final long serialVersionUID = -6894377399169392242L;
   
private Long idInstallation;
   
private UsersDTO users;
   
private String name;
   
private String description;

   
public InstallationDTO() {
   
}

   
public InstallationDTO(UsersDTO users) {
       
this.users = users;
   
}

   
public InstallationDTO(UsersDTO users, String name, String description) {
       
this.users = users;
       
this.name = name;
       
this.description = description;
   
}

   
   
public Long getIdInstallation() {
       
return idInstallation;
   
}

   
public void setIdInstallation(Long idInstallation) {
       
this.idInstallation = idInstallation;
   
}

   
public UsersDTO getUsers() {
       
return users;
   
}

   
public void setUsers(UsersDTO users) {
       
this.users = users;
   
}
   
   
public String getName() {
       
return name;
   
}

   
public void setName(String name) {
       
this.name = name;
   
}

   
public String getDescription() {
       
return description;
   
}

   
public void setDescription(String description) {
       
this.description = description;
   
}


I try to carry out mapping Hibernate for DTO:

public class InstallationMapper {

   
private List<InstallationDTO> installation;
   
   
public InstallationMapper(List<Installation> installation) {
       
ModelMapper mapper = new ModelMapper();
        mapper
.addMappings(new PropertyMap<Installation, InstallationDTO>() {

           
@Override
           
protected void configure() {
               
Converter<List<Installation>, List<InstallationDTO>> installationConverter = new Converter<List<Installation>, List<InstallationDTO>>() {

                   
@Override
                   
public List<InstallationDTO> convert(
                           
MappingContext<List<Installation>, List<InstallationDTO>> context) {
                       
List<InstallationDTO> result = new ArrayList<InstallationDTO>();
                       
for (Installation installation : context.getSource()) {
                           
InstallationDTO dto = new InstallationDTO();
                            dto
.setIdInstallation(installation.getIdInstallation());
                            dto
.setName(installation.getName());
                            dto
.setDescription(installation.getDescription());
                            result
.add(dto);
                       
}
                       
return result;
                   
}
               
};
                mapper
.addConverter(installationConverter);
           
}
       
});
       
Type listType = new TypeToken<List<InstallationDTO>>() {}.getType();
       
this.installation = mapper.map(installation, listType);
   
}

   
public List<InstallationDTO> getInstallation() {
       
return installation;
   
}
}



However, I get an exception:


INFO] Hibernate:
[INFO]     select
[INFO]         this_.ID_LANGUAGE_TEXT as ID_LANGU1_3_2_,
[INFO]         this_.ID_GUI_NAME as ID_GUI_N2_3_2_,
[INFO]         this_.ISO_LANGUAGE as ISO_LANG3_3_2_,
[INFO]         this_.COMPONENT_NAME as COMPONEN4_3_2_,
[INFO]         this_.LANGUAGE_TEXT as LANGUAGE5_3_2_,
[INFO]         guiname2_.ID_GUI_NAME as ID_GUI_N1_0_0_,
[INFO]         guiname2_.NAME as NAME2_0_0_,
[INFO]         language1_.ISO_LANGUAGE as ISO_LANG1_2_1_,
[INFO]         language1_.NAME as NAME2_2_1_,
[INFO]         language1_.FLAG as FLAG3_2_1_
[INFO]     from
[INFO]         WebMuseum.LANGUAGE_TEXT this_
[INFO]     inner join
[INFO]         WebMuseum.GUI_NAME guiname2_
[INFO]             on this_.ID_GUI_NAME=guiname2_.ID_GUI_NAME
[INFO]     inner join
[INFO]         WebMuseum.LANGUAGE language1_
[INFO]             on this_.ISO_LANGUAGE=language1_.ISO_LANGUAGE
[INFO]     where
[INFO]         language1_.ISO_LANGUAGE=?
[INFO]     order by
[INFO]         guiname2_.NAME asc
[INFO] Hibernate:
[INFO]     select
[INFO]         this_.ID_USERS as ID_USERS1_4_0_,
[INFO]         this_.ISO_LANGUAGE_DEFAULT as ISO_LANG2_4_0_,
[INFO]         this_.LOGIN as LOGIN3_4_0_,
[INFO]         this_.PASSWORD as PASSWORD4_4_0_,
[INFO]         this_.LAST_LOGGED as LAST_LOG5_4_0_
[INFO]     from
[INFO]         WebMuseum.USERS this_
[INFO]     where
[INFO]         this_.LOGIN=?
[INFO]         and this_.PASSWORD=?
[INFO]
[INFO] Hibernate:
[INFO]     select
[INFO]         this_.ID_INSTALLATION as ID_INSTA1_1_0_,
[INFO]         this_.ID_USERS as ID_USERS2_1_0_,
[INFO]         this_.NAME as NAME3_1_0_,
[INFO]         this_.DESCRIPTION as DESCRIPT4_1_0_
[INFO]     from
[INFO]         WebMuseum.INSTALLATION this_
[INFO]     where
[INFO]         this_.ID_USERS=?
[ERROR] lis 15, 2016 8:22:15 PM com.gwtplatform.dispatch.rpc.server.AbstractDispatchServiceImpl execute
[ERROR] WARNING: Service exception while executing pl.cba.lukaszbaczek.webMuseumService.client.choiceInstall.InstallList: Service exception executing action "InstallList", org.modelmapper.MappingException: ModelMapper mapping errors:
[ERROR]
[ERROR] 1) Converter org.modelmapper.internal.converter.CollectionConverter@28bf75c9 failed to convert java.util.ArrayList to java.util.List.
[ERROR]
[ERROR] 1 error
[ERROR] com.gwtplatform.dispatch.rpc.shared.ServiceException: Service exception executing action "InstallList", org.modelmapper.MappingException: ModelMapper mapping errors:
[ERROR]
[ERROR] 1) Converter org.modelmapper.internal.converter.CollectionConverter@28bf75c9 failed to convert java.util.ArrayList to java.util.List.
[ERROR]
[ERROR] 1 error
[ERROR]     at com.gwtplatform.dispatch.rpc.server.AbstractDispatchImpl.doExecute(AbstractDispatchImpl.java:164)
[ERROR]     at com.gwtplatform.dispatch.rpc.server.AbstractDispatchImpl.execute(AbstractDispatchImpl.java:110)
[ERROR]     at com.gwtplatform.dispatch.rpc.server.AbstractDispatchServiceImpl.execute(AbstractDispatchServiceImpl.java:87)
[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]     at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR]     at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:561)
[ERROR]     at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:265)
[ERROR]     at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:305)
[ERROR]     at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
[ERROR]     at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
[ERROR]     at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
[ERROR]     at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:263)
[ERROR]     at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:178)
[ERROR]     at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:91)
[ERROR]     at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:62)
[ERROR]     at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:118)
[ERROR]     at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:113)
[ERROR]     at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1474)
[ERROR]     at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:499)
[ERROR]     at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
[ERROR]     at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
[ERROR]     at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
[ERROR]     at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
[ERROR]     at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428)
[ERROR]     at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
[ERROR]     at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
[ERROR]     at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
[ERROR]     at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
[ERROR]     at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:68)
[ERROR]     at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
[ERROR]     at org.eclipse.jetty.server.Server.handle(Server.java:370)
[ERROR]     at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
[ERROR]     at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:960)
[ERROR]     at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1021)
[ERROR]     at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865)
[ERROR]     at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
[ERROR]     at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
[ERROR]     at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:668)
[ERROR]     at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
[ERROR]     at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
[ERROR]     at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
[ERROR]     at java.lang.Thread.run(Thread.java:745)
[ERROR] Caused by: org.modelmapper.MappingException: ModelMapper mapping errors:
[ERROR]
[ERROR] 1) Converter org.modelmapper.internal.converter.CollectionConverter@28bf75c9 failed to convert java.util.ArrayList to java.util.List.
[ERROR]
[ERROR] 1 error
[ERROR]     at org.modelmapper.internal.Errors.throwMappingExceptionIfErrorsExist(Errors.java:374)
[ERROR]     at org.modelmapper.internal.MappingEngineImpl.map(MappingEngineImpl.java:69)
[ERROR]     at org.modelmapper.ModelMapper.mapInternal(ModelMapper.java:497)
[ERROR]     at org.modelmapper.ModelMapper.map(ModelMapper.java:429)
[ERROR]     at pl.cba.lukaszbaczek.webMuseumDTO.server.installation.InstallationMapper.<init>(InstallationMapper.java:46)
[ERROR]     at pl.cba.lukaszbaczek.webMuseumService.server.choiceInstall.InstallListHandler.execute(InstallListHandler.java:29)
[ERROR]     at pl.cba.lukaszbaczek.webMuseumService.server.choiceInstall.InstallListHandler.execute(InstallListHandler.java:18)
[ERROR]     at com.gwtplatform.dispatch.rpc.server.AbstractDispatchImpl.doExecute(AbstractDispatchImpl.java:154)
[ERROR]     ... 43 more
[ERROR] Caused by: org.modelmapper.MappingException: ModelMapper mapping errors:
[ERROR]
[ERROR] 1) Failed to get value from pl.cba.lukaszbaczek.webMuseumDatabase.client.mapping.Users.getIsoLanguageDefault()
[ERROR]
[ERROR] 1 error
[ERROR]     at org.modelmapper.internal.Errors.toMappingException(Errors.java:258)
[ERROR]     at org.modelmapper.internal.PropertyInfoImpl$MethodAccessor.getValue(PropertyInfoImpl.java:100)
[ERROR]     at org.modelmapper.internal.MappingEngineImpl.resolveSourceValue(MappingEngineImpl.java:189)
[ERROR]     at org.modelmapper.internal.MappingEngineImpl.propertyMap(MappingEngineImpl.java:156)
[ERROR]     at org.modelmapper.internal.MappingEngineImpl.typeMap(MappingEngineImpl.java:131)
[ERROR]     at org.modelmapper.internal.MappingEngineImpl.map(MappingEngineImpl.java:101)
[ERROR]     at org.modelmapper.internal.MappingEngineImpl.setDestinationValue(MappingEngineImpl.java:246)
[ERROR]     at org.modelmapper.internal.MappingEngineImpl.propertyMap(MappingEngineImpl.java:180)
[ERROR]     at org.modelmapper.internal.MappingEngineImpl.typeMap(MappingEngineImpl.java:131)
[ERROR]     at org.modelmapper.internal.MappingEngineImpl.map(MappingEngineImpl.java:92)
[ERROR]     at org.modelmapper.internal.converter.IterableConverter.convert(IterableConverter.java:49)
[ERROR]     at org.modelmapper.internal.MappingEngineImpl.convert(MappingEngineImpl.java:336)
[ERROR]     at org.modelmapper.internal.MappingEngineImpl.map(MappingEngineImpl.java:96)
[ERROR]     at org.modelmapper.internal.MappingEngineImpl.map(MappingEngineImpl.java:60)
[ERROR]     ... 49 more
[ERROR] Caused by: java.lang.reflect.InvocationTargetException
[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]     at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR]     at org.modelmapper.internal.PropertyInfoImpl$MethodAccessor.getValue(PropertyInfoImpl.java:95)
[ERROR]     ... 61 more
[ERROR] Caused by: org.hibernate.LazyInitializationException: could not initialize proxy - no Session
[ERROR]     at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:148)
[ERROR]     at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:266)
[ERROR]     at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:68)
[ERROR]     at pl.cba.lukaszbaczek.webMuseumDatabase.client.mapping.Users_$$_jvste85_4.getIsoLanguageDefault(Users_$$_jvste85_4.java)
[ERROR]     ... 66 more
[ERROR]
[ERROR] com.gwtplatform.dispatch.rpc.shared.ServiceException: Service exception executing action "InstallList", org.modelmapper.MappingException: ModelMapper mapping errors:
[ERROR]
[ERROR] 1) Converter org.modelmapper.internal.converter.CollectionConverter@28bf75c9 failed to convert java.util.ArrayList to java.util.List.
[ERROR]
[ERROR] 1 error
[ERROR]     at com.gwtplatform.dispatch.rpc.shared.ServiceException_FieldSerializer.instantiate(ServiceException_FieldSerializer.java:16)
[ERROR]     at com.gwtplatform.dispatch.rpc.shared.ServiceException_FieldSerializer.create(ServiceException_FieldSerializer.java:25)
[ERROR]     at com.google.gwt.user.client.rpc.impl.SerializerBase.instantiate(SerializerBase.java:115)
[ERROR]     at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:396)
[ERROR]     at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:119)
[ERROR]     at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:216)
[ERROR]     at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:259)
[ERROR]     at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:412)
[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]     at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR]     at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
[ERROR]     at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
[ERROR]     at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
[ERROR]     at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
[ERROR]     at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
[ERROR]     at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
[ERROR]     at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:576)
[ERROR]     at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:284)
[ERROR]     at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
[ERROR]     at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
[ERROR]     at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:356)
[ERROR]     at sun.reflect.GeneratedMethodAccessor69.invoke(Unknown Source)
[ERROR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]     at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR]     at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
[ERROR]     at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
[ERROR]     at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
[ERROR]     at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
[ERROR]     at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
[ERROR]     at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
[ERROR]     at java.lang.Thread.run(Thread.java:745)


Please help

Regards
J-23

Jesse Kommu

non lue,
30 oct. 2017, 17 h 37 min 29 s2017-10-30
à modelmapper
Hello !
I have the same problem. 
Can you please share the solution if you have found one..

thanks

Chun Han Hsiao

non lue,
13 déc. 2017, 03 h 12 min 43 s2017-12-13
à modelmapper
Hi,

Thanks for the report, can you try update your code as below and check that the exception still appeared or not? Thanks!

public class InstallationMapper {
private List<InstallationDTO> installation;
public InstallationMapper(List<Installation> installation) {
Converter<Installation, InstallationDTO> installationConverter = new Converter<Installation, InstallationDTO>() {
@Override
public InstallationDTO convert(MappingContext<Installation, InstallationDTO> context) {
InstallationDTO dto = new InstallationDTO();
dto.setIdInstallation(installation.getIdInstallation());
dto.setName(installation.getName());
dto.setDescription(installation.getDescription());
return dto;
}
};
mapper.addConverter(installationConverter);

Type listType = new TypeToken<List<InstallationDTO>>() {}.getType();
this.installation = mapper.map(installation, listType);
}

public List<InstallationDTO> getInstallation() {
return installation;
}
}



Regards,
Chun Han

J-23於 2016年11月16日星期三 UTC+8上午4時03分43秒寫道:
Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message