title: One Service Two Repo
body: <p>Title as shown below.  The problem is when I call EDIRepoName.findById(shortName) I get an error that implies it is using the wrong repo.  (I will guarantee the shortName is unique, but I need to lookup by it.)</p>
  
  <blockquote>
    <p>Wed May 27 09:43:49 EDT 2020 There was an unexpected error
    (type=Internal Server Error, status=500). Provided id of the wrong
    type for class com.example.ta_edi.model.EDIType. Expected: class
    java.lang.Long, got class java.lang.String; nested exception</p>
  </blockquote>
  
  <pre><code>public class EDITypeService {
      @Autowired
      EDITypeRepository ediRepo;
      @Autowired
      EDITypeNameRepository ediRepoName;
  
  public interface EDITypeRepository extends CrudRepository&lt;EDIType,Long&gt; {   
  
  }
  
  public interface EDITypeNameRepository extends CrudRepository&lt;EDIType,String&gt; {
  }
  
  
  
  public Optional&lt;EDIType&gt; getByShort(EDIType ediType) {
          //dangerous.assume shortName is unique.
          String shortName = ediType.getShortName();
          Optional&lt;EDIType&gt; found = ediRepoName.findById(shortName);
          return found; 
      }
  </code></pre>
  
  <p>Updated:
  Can I not have a repository that does a lookup on a non-primary key? If so that would explain the error.  Then how do I lookup by other than a primary key?</p>
  
  <pre><code>@Entity
  public class EDIType {
      @Id
      @GeneratedValue
      Long index;
      @CreationTimestamp
      LocalDateTime created;
      @UpdateTimestamp
      LocalDateTime updated;
      String shortName; 
      String processType; 
      @Lob
      Clob xmlFile;
  </code></pre>
  
  <p>Thank you, but I did this modification first below and got the error second below</p>
  
  <pre><code>public interface EDITypeNameRepository extends CrudRepository&lt;EDIType,String&gt; {     
      @Query("SELECT p FROM EDIType WHERE LOWER(p.shortName)=LOWER(:shortName)")
          public List&lt;EDIType&gt; byShortName(@Param("shortName") String shortName);
  
  }
  </code></pre>
  
  <blockquote>
    <p>Error creating bean with name 'EDITypeNameRepository': FactoryBean
    threw exception on object creation; nested exception is
    java.lang.IllegalArgumentException: Validation failed for query for
    method public abstract java.util.List
    com.example.ta_edi.repository.EDITypeNameRepository.byShortName(java.lang.String)!</p>
  </blockquote>