0

I am missing something when adding a new method but I do not know what ?? It is generating a cannot find symbol compilation error in userDAO.countUsers line :

@Autowired
private UserDAO userDAO;

    @Async
private Future<Long> searchCount(MultiValueMap<String, String> parameters) throws DaoException {


   userDAO.countUsers("bla bla");


    return new AsyncResult<Long>(Long.getLong("1")); // temp code
}

Here is the service interface :

public interface UserDAO {

long countUsers(String bloblo) throws DaoException;

And here is the implementation :

    @Service("userDAO")
    @SuppressWarnings("unchecked")
    @Transactional(readOnly = true, timeout = Constants.TRANSACTION_TIMEOUT, propagation = Propagation.SUPPORTS)
    public class UserDaoImpl implements UserDAO {

@PersistenceContext
private EntityManager em;

   @Override
    public long countUsers(String bloblo) throws DaoException {
        // Build request
        final QueryCriteria qc = new QueryCriteria(bloblo);

        final StringBuilder request = prepareQuery(qc);
        request.replace(7, 21, "count(distinct user)");
        final Query query = em.createQuery(request.toString());

        // Build parameters
        addParameters(query, qc);

        // Execute
        try {
            return (Long) query.getSingleResult();
        } catch (final RuntimeException e) {
            LOG.error(e.getMessage(), e);
            throw new DaoException(e);
        }
    }

Help really appreciated !

benek
  • 2,088
  • 2
  • 26
  • 38
  • I expect the arguments you are calling `UserDAO.countUsers` with do not match the declared argument types in the interface. You need to go through each argument where you are calling it and ensure that it is of the type defined in the interface – beresfordt Mar 14 '16 at 11:35
  • I did this. I even tried creating a new method count(Long) with one unique argument and I have the same error. – benek Mar 14 '16 at 11:37

3 Answers3

1

Make sure, that you did import of classes from userDAO.countUsers() invocation (LanguageCode, UserType, UserRightOrder). Maybe you should paste your error message?

Anad
  • 848
  • 7
  • 8
0

May be you have not declared variable em in line

em.createQuery(request.toString());
dinesh.kumar
  • 167
  • 1
  • 10
0

It is a problem with my maven version (3.0.5) having problem with JDK1.7. I upgraded to 3.3.x version and now it works.

Thanks to :

maven "cannot find symbol" message unhelpful

Community
  • 1
  • 1
benek
  • 2,088
  • 2
  • 26
  • 38