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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:20:37+00:00 2026-05-20T15:20:37+00:00

I have a domain object, Expense, that has a field called initialFields . It’s

  • 0

I have a domain object, Expense, that has a field called initialFields.

It’s annotated as so:

@OneToMany(fetch = FetchType.EAGER, cascade = { CascadeType.ALL }, orphanRemoval = true)
@JoinTable(blah blah)
private final List<Field> initialFields;

Now I’m trying to use Projections in order to only pull certain fields for performance reasons, but when doing so the initialFields field is always null. It’s the only OneToMany field and the only field I am trying to retrieve with the projection that is behaving this way. If I use a regular HQL query initialFields is populated appropriately, but of course I can’t limit the fields.

Partial projection code:

Criteria criteria = session.createCriteria(Payment.class);
criteria.createAlias("expense", "e");

ProjectionList properties = Projections.projectionList();
//Some restrictions and more fields
properties.add(Projections.property("e.initialFields"), "initialFields");
criteria.setProjection(properties);
criteria.setFetchMode("e.initialFields", FetchMode.JOIN);
criteria.setReadOnly(true);
criteria.setResultTransformer(Transformers.aliasToBean(Expense.class));

return criteria.list();

When I turn on debugging and turn on show sql, the query to pull the initialFields doesn’t appear to be created/run. Anyone ever seen anything like this?

I’ve just tried using HQL projection, by specifying each field I want to pull and then manually building the object. In this case the SQL built by Hibernate is incorrect for the initialFields field. expense1_.name as col_1_0_, . as col_2_0_, expense1_.account_id as col_3_0_. The . as col_2_0_ is where the initialFields would be pulled. My guess is that it should be expense1_.id as col_2_0_.

Edit: I just removed the Result Transformer to inspect each property and the initialFields property is indeed null.

  • 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-20T15:20:38+00:00Added an answer on May 20, 2026 at 3:20 pm

    I had similar problem and for me was working explicitly specifying joinType in criteria.

    Criteria criteria = session.createCriteria(Payment.class);
    criteria.createAlias("expense", "e", CriteriaSpecification.LEFT_JOIN);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a domain object that has been auto generated for me by MyGeneration.
I have a domain object that has a couple of Uri properties that need
I have a domain object that has an attribute which is a collection containing
I have a basic domain object, say like Person or Campaign or Event that
I have a property on a domain object that is declared in a many-to-one
I have the current basic structure for each domain object that I need to
I have a domain object that stores some metadata and some raw bytes. This
So basically i have a domain object and a generic repository that can do
I have an abstract domain object that is consumed by both a web and
So let's say we have a domain object such as the following public class

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.