Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7941995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:50:05+00:00 2026-06-03T23:50:05+00:00

I am trying to create a query using hibernate following the example given in

  • 0

I am trying to create a query using hibernate following the example given in section 9.2 of chapter 9

The difference with my attempt is I am using spring MVC 3.0. Here is my Address class along with the method i created.

@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<Tuple> jqgridAddresses(Long pID){
        CriteriaBuilder builder = Address.entityManager().getCriteriaBuilder();
        CriteriaQuery<Tuple> criteria = builder.createTupleQuery();
        Root<Address> addressRoot = criteria.from( Address.class );
        criteria.multiselect(addressRoot.get("id"), addressRoot.get("street1"), addressRoot.get("street2"));
        criteria.where(builder.equal(addressRoot.<Set<Long>>get("id"), pID));
        return Address.entityManager().createQuery( criteria ).getResultList();
    }
}

The method called jqgridAddresses above is the focus. I opted not to use the “Path” because when I say something like Path idPath = addressRoot.get( Address_.id ); as in section 9.2 of the documentation, the PathAddress_.id stuff produces a compilation error.

The method above returns an empty list of type Tuple as its size is zero even when it should contain something. This suggests that the query failed. Can someone please advise me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T23:50:06+00:00Added an answer on June 3, 2026 at 11:50 pm

    OK so i made some minor adjustments to my logic which is specific to my project, however, the following approach worked perfectly. Hope it hepls someone in need !

    @Transient
    public static List<Tuple> jqgridPersons(Boolean isStudent, String column, String orderType, int limitStart, int limitAmount){
        CriteriaBuilder builder = Person.entityManager().getCriteriaBuilder();
        CriteriaQuery<Tuple> criteria = builder.createTupleQuery();
        Root<Person> personRoot = criteria.from(Person.class );
        criteria.select(builder.tuple(personRoot.get("id"), personRoot.get("firstName"), personRoot.get("lastName"), personRoot.get("dateOfBirth"), personRoot.get("gender"), personRoot.get("maritalStatus"))); 
        criteria.where(builder.equal( personRoot.get("isStudent"), true));
        if(orderType.equals("desc")){
            criteria.orderBy(builder.desc(personRoot.get(column)));
        }else{
            criteria.orderBy(builder.asc(personRoot.get(column)));
        }
        return Address.entityManager().createQuery( criteria ).setFirstResult(limitStart).setMaxResults(limitAmount).getResultList(); 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to execute a simple stored procedure with Spring/Hibernate using Annotations. Here are
I am trying to create a not in query using hibernate Criteria. What I
I'm trying to create a Union between two tables, using HQL (Hibernate Query Language).
We are trying to create/query information from a CF based on the following structure
I'm trying to create a table of information in a database query using Zend
I am trying to create a query using QueryOver , which will fetch a
I've got the following named query in Hibernate: <sql-query name=CreateLogTable> CREATE TABLE IF NOT
I'm trying to code the following HQL query using the Criteria API: var userList
I'm trying to call a stored procedure using Hibernate, but I'm getting the following
I'm trying to create a SQL query in NHibernate using CreateSQLQuery: var query =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.