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 7930225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:21:19+00:00 2026-06-03T20:21:19+00:00

In short: A user has many not clients (these are the clients the user

  • 0

In short: A user has many “not clients” (these are the clients the user cannot serve). User is associated to multiple clients through a join table.

User class: https://gist.github.com/dd99690fcaaba2c834d6

Client class: https://gist.github.com/10de71bcd1914ded5fb9

DAO: https://gist.github.com/dd4a369d60a05460d0c0

the “notClients” attribute in User is always null, can anyone help me understand why?

  • 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-03T20:21:21+00:00Added an answer on June 3, 2026 at 8:21 pm

    In short, because you’re not including it in your select query. Not sure why you’re writing out SQL queries and using the bean transformer? That’s a very strange way to use hibernate. In the end it means what you’re getting back is not a hibernate managed entity. It’s just an object with the specific stuff that you selected mapped onto it.

    The “normal”/”correct” way to use hibernate would be something like this:

    private User getUser(int id, String userType)
    {
        User result;
    
        session = HibernateUtil.getWilsonsSessionFactory().getCurrentSession();
        session.beginTransaction();
    
        Query query = session.createQuery("select u from User u 
                                           where u.id = :id and u.role = :role");
        query.setParameter("id", id);
        query.setParameter("role", userType);
    
        result = (User)query.uniqueResult();
    
        session.getTransaction().commit();
    
        return result;  
    }
    

    Then what you get back is an Hibernate entity that will have all its mapped properties populated.

    (would not personally use uniqueResult in that way either, but I am willing to admit that is largely a style preference.)

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

Sidebar

Related Questions

Short database schema: users (id) games (current_player_id) // has many cards cards (author_id, game_id,
DGV has no AllowSort property. How can I prevent user to sort the items?
Short version: I'm trying to determine the best way to track what the user
Short question: Is it possible to do a redirection, say when a user isn't
I am using a dropdown to allow the user to sort search results. These
I've embedded all the activities for a user and let's say most user has
I have a simple Invoices class with a Number attribute that has to be
I have a Post model: class Post < ActiveRecord::Base belongs_to :user has_many :taggings, :dependent
What I have is a table with elements. Each element has a unique id
My rails app has a simple model Links which tracks all the Urls associated

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.