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

  • Home
  • SEARCH
  • 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 8841427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:42:54+00:00 2026-06-14T10:42:54+00:00

I need a HQL Query but I just dont get it. SELECT * FROM

  • 0

I need a HQL Query but I just dont get it.

SELECT * FROM Poll WHERE pid NOT IN (
SELECT pid FROM votes WHERE uid =  'theuserid')

I want all List of Poll´s back where the uid not in the table votes exists.

Also helpfull would be the hql query where the uid in the table votes exists, but I guess this is very similar 😉

These are the 2 classes:

public class Poll {

private int pid;
private String name;
private String description;
private Date deadline;
private Set<Team> teams = new HashSet<Team>(0);
//some getter & setter
}

public class Vote {

private int vid;
private String uid;
private int pid;
private int tid;
private int votes;
//some getter & setter
}

Can smbdy please help me. I guess it is a join with a WHERE and NOT LIKE but I just dont get it.

Merci!

This is btw the hibernate mapping:

 <hibernate-mapping>
 <class name="package.model.Poll" table="poll">
 <id name="pid" column="pid" >
 <generator class="increment"/>
 </id>
<property name="name" column="name" />
<property name="description" column="description" />
<property name="deadline" type="timestamp" column="deadline" />

<set name="teams" table="pollchoice" 
        inverse="false" lazy="false" fetch="select" cascade="all" >
        <key>
            <column name="pid" not-null="true" />
        </key>
        <many-to-many entity-name="knt.exceedvote.model.Team">
            <column name="tid" not-null="true" />
        </many-to-many> 
</set>
 </class>
 </hibernate-mapping> 

 <hibernate-mapping>
   <class name="package.model.Vote" table="votes">
    <id name="vid" column="vid" >
    <generator class="increment"/>
   </id>
<property name="pid" column="pid" />
<property name="uid" column="uid" />
<property name="tid" column="tid" />
<property name="votes" column="votes" />


  </class>
 </hibernate-mapping>
  • 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-14T10:42:55+00:00Added an answer on June 14, 2026 at 10:42 am

    Please keep in mind, Hibernate is designed using the notion of Object Graph, which is a name given to the relational objects.

    That core concept is missing in your mapping (Poll and Vote seem to be isolated) hence I doubt you can use HQL in its current state.

    In my opinion, you have two options:

    1. Define the relationship between Poll, pid and Vote, uid. Then you should be able to write simple HQL.

    2. Use native SQL through Hibernate session itself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to return a constant from an HQL query in NHIbernate SELECT new
I need to convert this SQL query to HQL select * from ( select
I have this hql query, which works perfect: select m from Media m join
I need to replicate the following working HQL query using criteria API. session.CreateQuery( select
HQL query against a PostgreSQL database: var checkLines = _Session.CreateQuery( @select lines from FinancialStatement
I need to build an HQL query that uses the same entity twice, but
I am trying to make a query in hibernate criteria (not in hql) but
I need to select some entities using HQL filtering by time. But I need
i need to convert this HQL: FROM Appointment a WHERE (a.group==null OR :user MEMBER
I've got a hibernate query I'm trying to get working but keep getting an

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.