2017-01-23 6 views
1

Я использую интероперабельность между Scala и Java и имею следующий код, который использует Scala, для создания экземпляра класса в том же проекте, который был написан на Java. Параметр CommandExecutor наследуется от родительского класса.Scala не может разрешить конструктор

class IdmIdentityServiceImpl extends ServiceImpl with IdmIdentityService { 
    override def createNativeUserQuery: NativeUserQuery = { 
     new NativeUserQueryImpl(commandExecutor) 
     } 
} 

Я получаю сообщение об ошибке, в инстанцировании NativeUserQueryImpl, что говорит cannot resolve constructor

NativeUserQueryImpl был написан на Java, но я читал о совместимости между Java и Scala и чувствовать себя, как он должен работать.

Это класс NativeUserQueryImpl, который принимает тип CommandExecutor в одном из его конструкторов. Класс поставляется из библиотеки с текущими двигателями.

public class NativeUserQueryImpl extends AbstractNativeQuery<NativeUserQuery, User> implements NativeUserQuery { 

    private static final long serialVersionUID = 1L; 

    public NativeUserQueryImpl(CommandContext commandContext) { 
    super(commandContext); 
    } 

    public NativeUserQueryImpl(CommandExecutor commandExecutor) { 
    super(commandExecutor); 
    } 

    // results //////////////////////////////////////////////////////////////// 

    public List<User> executeList(CommandContext commandContext, Map<String, Object> parameterMap, int firstResult, int maxResults) { 
    return commandContext.getUserEntityManager().findUsersByNativeQuery(parameterMap, firstResult, maxResults); 
    } 

    public long executeCount(CommandContext commandContext, Map<String, Object> parameterMap) { 
    return commandContext.getUserEntityManager().findUserCountByNativeQuery(parameterMap); 
    } 

} 

EDIT:

Полная ошибка

Error:(31, 5) overloaded method constructor NativeUserQueryImpl with alternatives: 
    (x$1: org.flowable.idm.engine.impl.interceptor.CommandExecutor)org.flowable.idm.engine.impl.NativeUserQueryImpl <and> 
    (x$1: org.flowable.idm.engine.impl.interceptor.CommandContext)org.flowable.idm.engine.impl.NativeUserQueryImpl 
cannot be applied to (org.flowable.engine.impl.interceptor.CommandExecutor) 
    new NativeUserQueryImpl(commandExecutor) 
+0

Где определяется 'commandExecutor'? – nmat

+0

@nmat в том же проекте – Rafa

+0

Наследуется от родительского класса. Я добавляю полную подпись класса, в которой это содержится. Он находится в 'ServiceImpl' – Rafa

ответ

0

Из полной ошибки, публикуемую в оригинальный вопрос, оказывается, что CommandExecutor, который наследуется от родительского класса ServiceImpl имеет две различные версии в библиотека

org.flowable.idm.engine.impl.interceptor.CommandExecutor и org.flowable.engine.impl.interceptor.CommandExecutor, где тонкая разница заключается в том, что один из пакетов idm, а другой нет.

Изменение ServiceImpl из второго пакета в первый, обновляет параметр CommandExecutor, который передается, и исправляет проблему.