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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:44:31+00:00 2026-06-14T07:44:31+00:00

I write named query like this <query name=GET_QUESTIONS_BY_TEST_ID>select tq from TestQuestion as tq inner

  • 0

I write named query like this

<query name="GET_QUESTIONS_BY_TEST_ID">select tq from TestQuestion as tq inner join tq.question as
        q
        where
        tq.testQuestionIdentifer.versionId=(select
        max(tq.testQuestionIdentifer.versionId) from TestQuestion tq_inner
        where
        tq_inner.testQuestionIdentifer.testId=:testId) and
        tq.testQuestionIdentifer.testId=:testId
    </query>

And when I get result I have a problem. When I write just from TestQuestion I get List<Object[Object[]]> with Question and TestQuestion objects. When I write select tq I get LazyInitializationException. I want to get List but can’t.

UPDATED

I decided add other part my hbm

<class name="by.bsuir.testapp.model.TestQuestion" table="TEST_QUESTION"
        lazy="true">
        <composite-id name="testQuestionIdentifer"
            class="by.bsuir.testapp.model.TestQuestionIdentifer">
            <key-property name="testId" column="TEST_ID" />
            <key-property name="versionId" column="VERSION_ID" />
            <key-property name="questionId" column="QUESTION_ID" />
        </composite-id>
        <many-to-one name="question" class="by.bsuir.testapp.model.Question"
            fetch="join" insert="false" update="false">
            <column name="QUESTION_ID" />
        </many-to-one>
    </class>

I find that exist 11.4.1.2. Queries that return tuples in documentation of Hibernate documentation

How I should write named query for rignt result?

  • 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-14T07:44:32+00:00Added an answer on June 14, 2026 at 7:44 am

    I don’t get your problem.

    Your query (select tq from TestQuestion as tq... and from TestQuestion) should both return List<TestQuestion> instead of List<Object[][]>

    LazyInitializationException normally occur when there is lazy-fetching occurring, but the related session of the entity is closed already (please correct me if I am wrong, just from my bare memory I thought it is LazyInitializationException). It has nothing to do with named query. Please make sure your transaction control etc is setup correctly.

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

Sidebar

Related Questions

I need to write a query like this, any help please? select id, parent,
Using the C# compilers query comprehension features, you can write code like: var names
I'm using the following code to write data through a named pipe from one
My SQL table is something like this: id, name, value1, value2, value3, value4 1,
Good day, I have like 2 question here: First a background information. from the
I have an intermediate table which looks something like this (after I join 2
I have an XML field in SQL table like this <Root> <Name>Apollo</Name> <Code>1000</Code> <Code>2000</Code>
Here is the updated question: the current query is doing something like: $sql1 =
I am having a problem with the following query(if this is a duplicate question
I'm trying to write a named scope that will order my 'Products' class based

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.