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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:01:51+00:00 2026-05-14T19:01:51+00:00

i have a table like this one: id | name | score mapped to

  • 0

i have a table like this one:

id | name | score

mapped to a POJO via XML with Hibernate. The score column i only need in oder by – clauses in HQL. The value for the score column is calculated by an algorithm and updated every 24 hours via SQL batch process (JDBC). So i dont wanna pollute my POJO with properties i dont need at runtime.

For a single column that may be not a problem, but i have several different score columns.
Is there a way to map a property for HQL use only?

For example like this:

<property name="score" type="double" ignore="true"/>

so that i still can do this:

from Pojo p order by p.score

but my POJO implementation can look like this:

public class Pojo
{
  private long id;

  private String name;

  // ... 
}

No Setter for score provided or property added to implementation.

using the latest Hibernate version for Java.

Update:

In a perfect world it can be done like this (thanks to Pascal Thivent):

<property name="score" access="noop" insert="false" update="false"/>

But in our real world there exists a bug since years which nobody seems to care about. So does anyone have a suggestions for a workaround?

  • 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-05-14T19:01:52+00:00Added an answer on May 14, 2026 at 7:01 pm

    You can use access="noop" in your mapping to specify query-only properties (that’s a secret, non documented feature, see HHH-552):

    <property name="score" access="noop" insert="false" update="false" ... />
    

    Update: Just to clarify, with the following Entity:

    public class EntityWithHqlOnlyProperty implements Serializable {
        private Long id;
        private String name;
    
        //...
    }
    

    And this mapping:

    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <hibernate-mapping>
        <class name="com.stackoverflow.q2812672.EntityWithHqlOnlyProperty" table="EntityWithHqlOnlyProperty">
            <id name="id" type="java.lang.Long">
                <column name="id" />
                <generator class="assigned" />
            </id>
            <property name="name" type="string">
                <column name="name" not-null="true" />
            </property>
            <property name="score" type="double" access="noop" insert="false" update="false"/>
        </class>
    </hibernate-mapping>
    

    The following snippet:

     Query q = session.createQuery("from EntityWithHqlOnlyProperty e order by e.score");
     List<EntityWithHqlOnlyProperty> resultList = q.list();
     assertNotNull(resultList);
    

    generates the following SQL:

    select 
      entitywith0_.id as id6_, 
      entitywith0_.name as name6_, 
      entitywith0_.score as score6_ 
     from 
      EntityWithHqlOnlyProperty entitywith0_ 
     order by
      entitywith0_.score
    

    And in my real world, the test just passes. This has been tested with Hibernate Core 3.3.2.GA on Derby and HSQLDB. In other words, it works on my machine (c).

    If it doesn’t for you – and I don’t mean to be rude but – in a perfect world you should provide a test case allowing to reproduce HHH-2925 as requested for 3+ years. Providing a way to reproduce a problem (I couldn’t) highly increases the chances to get it fixed.

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

Sidebar

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.