Note that there are some explanatory texts on larger screens.

plurals
  1. POHibernate tuple criteria queries
    primarykey
    data
    text
    <p>I am trying to create a query using hibernate following the example given in section 9.2 of <a href="http://docs.jboss.org/hibernate/entitymanager/3.5/reference/en/html/querycriteria.html#querycriteria-tuple" rel="nofollow">chapter 9</a></p> <p>The difference with my attempt is I am using spring MVC 3.0. Here is my Address class along with the method i created.</p> <pre><code>@RooJavaBean @RooToString @RooEntity @RooJson public class Address { @NotNull @Size(min = 1) private String street1; @Size(max = 100) private String street2; private String postalcode; private String zipcode; @NotNull @ManyToOne private City city; @NotNull @ManyToOne private Country country; @ManyToOne private AddressType addressType; @Transient public static List&lt;Tuple&gt; jqgridAddresses(Long pID){ CriteriaBuilder builder = Address.entityManager().getCriteriaBuilder(); CriteriaQuery&lt;Tuple&gt; criteria = builder.createTupleQuery(); Root&lt;Address&gt; addressRoot = criteria.from( Address.class ); criteria.multiselect(addressRoot.get("id"), addressRoot.get("street1"), addressRoot.get("street2")); criteria.where(builder.equal(addressRoot.&lt;Set&lt;Long&gt;&gt;get("id"), pID)); return Address.entityManager().createQuery( criteria ).getResultList(); } } </code></pre> <p>The method called <code>jqgridAddresses</code> above is the focus. I opted not to use the "<strong>Path"</strong> because when I say something like <strong>Path idPath = addressRoot.get( Address_.id );</strong> as in section 9.2 of the documentation, the <strong>PathAddress_.id</strong> stuff produces a compilation error.</p> <p>The method above returns an empty list of type <code>Tuple</code> as its size is zero even when it should contain something. This suggests that the query failed. Can someone please advise me.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload