title: How to convert a SQL query to Spring JPA query
body: <p>I have a SQL query like this:
  <code>"Select UIProfileID from UserTable where UPPER(UserID) = UPPER('?1')"</code>.</p>
  
  <p>I want to convert it to Spring JPA.
  I want to write <code>getUIProfileId()</code> and return Integer. But I don't know how to implement. Because User table doesn't have <code>UIProfileId</code> column that it was joined from <code>UIProfileTable</code> table. Please help me solve it. 
  Currently, I have tables:</p>
  
  <p><strong>User.java</strong></p>
  
  <pre><code>@Entity
  @Getter
  @Setter
  @NoArgsConstructor
  @AllArgsConstructor
  @Builder
  @Table(name = "UserTable")
  public class User {
  
    @Column(name = "UserID", length = 32, nullable = false)
    @Id
    private String name;
  
    @ManyToOne
    @JoinColumn(name = "DomainID", nullable = false)
    private Domain domain;
  
    @Column(name = "Password", length = 32, nullable = false)
    private String password;
  
    @ManyToOne
    @JoinColumn(name = "UIProfileID", nullable = false)
    private UIProfile uiProfile;
  
    @Column(name = "ResPerpage", nullable = false)
    private Integer resperpage;
  
    @Column(name = "DefaultTab")
    private Integer defaulttab;
  
    @ManyToOne
    @JoinColumn(name = "AdminProfile")
    private AdminProfiles adminProfile;
  
    @Column(name = "LanguageId")
    private Integer languageId;
  }
  </code></pre>
  
  <p><strong>UIProfile.java</strong></p>
  
  <pre><code>@Entity
  @Getter
  @Setter
  @Table(name = "UIProfileTable")
  public class UIProfile implements Serializable {
  
    @Id
    @Column(name = "UIProfileID", length = 11, nullable = false)
    private Integer id;
  
    @Column(name = "UIProfileName", length = 32, nullable = false)
    private String name;
  
    @OneToMany(mappedBy = "id.uiProfile")
    private List&lt;UIProfileTopLevel&gt; topLevels;
  }
  </code></pre>
  
  <p><strong>UserRepository.java</strong></p>
  
  <pre><code>public interface UserRepository extends Repository&lt;User, String&gt; {
  
    Optional&lt;User&gt; findOne(String name);
  
    @Query("Select UIProfileID from User where UPPER(UserID) = UPPER('admin')")
    Integer getUIProfileId();
  
  }
  </code></pre>