Package net.sf.autodao

Examples of net.sf.autodao.Named


    }
    if (Utils.getOffset(annotations) != null) {
      offsetCheck(type);
      processed = true;
    }
    final Named named = Utils.getNamed(annotations);
    if (processed) {
      if (named != null)
        throw new SpecificationViolationException("@Named cannot be present on @Limit/@Offset param", method);
    } else {
      if (named == null) {
        if (!names.isEmpty())
          throw new SpecificationViolationException("You're not allowed to mix @Named and indexed params", method);

        final int paramIndex = index + 1
            - (limit ? 1 : 0)
            - (offset ? 1 : 0);
        final Class<?> expectedType = getExpectedType(paramIndex);
        if (expectedType != null) {
          final Class<?> actualType = getActualParameterType(type, false);
          if (!expectedType.isAssignableFrom(actualType)) {
            final String msg = String.format("Indexed parameter '%s' of type %s cannot be assigned to query parameter of type %s", paramIndex, actualType.getName(), expectedType.getName());
            throw new SpecificationViolationException(msg, method);
          }
        }
        indexed++;
      } else {
        if (indexed > 0)
          throw new SpecificationViolationException("You're not allowed to mix @Named and indexed params", method);

        final String name = named.value();
        final Class<?> expectedType = getExpectedType(name);
        if (expectedType != null) {
          final Class<?> actualClass = getActualParameterType(type, true);
          if (!Collection.class.isAssignableFrom(actualClass) && !expectedType.isAssignableFrom(actualClass)) {
            final String msg = String.format("Named parameter '%s' of type %s cannot be assigned to query parameter of type %s", name, actualClass.getName(), expectedType.getName());
View Full Code Here


        if (processed)
          return;

        final Object queryArg = transformArg(arg, method.getParameterTypes()[index]);
        final Named named = Utils.getNamed(annotations);
        if (named == null) {
          queryArgs.add(queryArg);
        } else {
          namedArgs.put(named.value(), queryArg);
        }
      }
    });

    final FinderExecutor dao = (FinderExecutor) invocation.getThis();
View Full Code Here

TOP

Related Classes of net.sf.autodao.Named

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.