title: Return a boolean from a JpaRepository method
body: <p>I have a native query in an interface which extends <code>JpaRepository</code>. The method should ideally return a boolean value, but I can't figure out how to SELECT anything that gets automatically translated into <code>boolean</code>.</p>
  
  <p>This works, although I have to call it as <code>Boolean.valueOf(hasKids(id))</code>:</p>
  
  <pre><code>// yuck. I wanted a boolean
  @Query(nativeQuery = true, value = "select 'true' from dual where exists("
            + "select * from child_table where parent_id = ?)")
  String hasKids(long parentId);
  </code></pre>
  
  <p>How can I change this to the more natural return type?</p>
  
  <pre><code>boolean hasKids(long parentId);  // throws ClassCastException
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>the stacktrace is not very helpful IMHO because it's the usual nightmare of Hibernate proxies and AspectJ closures, but here's the relevant portion anyway.</p>
  
  <pre><code>Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean
      at com.sun.proxy.$Proxy1025.hasKids(Unknown Source)
      at com.bela.foo.bar.Service.ThingyServiceImpl.recordHasKids_aroundBody4(ThingyServiceImpl.java:85)
      at com.bela.foo.bar.Service.ThingyServiceImpl$AjcClosure5.run(ThingyServiceImpl.java:1)
  ...
  </code></pre>