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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:34:59+00:00 2026-05-27T12:34:59+00:00

I have some problems trying to get a bag collection of a class to

  • 0

I have some problems trying to get a bag collection of a class to be loaded through custom sql.
Here’s the xml mappings I have for my class

<hibernate-mapping>
<class name="alekso.npe.model.Utente" table="VNPEZZ_UTE_MAT" lazy="false">
    <id name="matricola" column="C_UTE_MAT">             
    </id>       
    <property name="nome" column="T_NOM" />
    <property name="cognome" column="T_COG" />
    <property name="email" column="T_EML" />

    <bag name="ruoli" table="VNPEZX_UTE_APP_TRN" 
        inverse="false" lazy="true" fetch="select" cascade="all" >
        <key column="C_UTE_MAT" />
        <one-to-many class="alekso.npe.model.Ruolo" />
        <loader query-ref="rolesQuery"/>
    </bag>
</class>
    <class name="alekso.npe.model.Ruolo" table="VNPEZH_TIP_USR"
    lazy="false" where="C_APP = 'NPE'">
    <id name="codice" column="C_TIP_USR">            
    </id>   
    <property name="nome" column="T_DES_TIP_USR"/>      

</class>
<sql-query name="rolesQuery">
    <return alias="role" class="alekso.npe.model.Ruolo"></return>
    <load-collection alias="ruoli" role="alekso.npe.model.Ruolo" ></load-collection>
    <![CDATA[select {ruolo.*}
    from NPEA.vnpezx_ute_app_trn permesso join NPEA.vnpezh_tip_usr ruolo
      on ruolo.c_tip_usr = permesso.c_tip_usr
      where permesso.c_app = 'NPE'
      and permesso.c_ute_mat = :matricola ]]>
</sql-query>
</hibernate-mapping>

But when I run the application I get an error:
org.hibernate.HibernateException: Errors in named queries: rolesQuery in the buildSessionFactory phase.
Can you tell me what’s wrong with this mapping?
I tried both with and without the <return> tag inside the <sql-query> but it still don’t work

  • 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-27T12:35:00+00:00Added an answer on May 27, 2026 at 12:35 pm

    I found out the error… the line <load-collection alias="ruoli" role="alekso.npe.model.Ruolo" ></load-collection> inside the custom query definition gives the error.
    Without that line, everything works fine (almost… the collection of roles is lazy loaded even if I set lazy=”false” everywhere).
    But that line I removed is on the documentation, so I’d like to know why it’s wrong.
    I’ll leave the question open for other to give some hints on this.

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

Sidebar

Related Questions

I'm trying to call a JavaScript function through PHP and have met some problems.
I began taking up Heroku again, but have had some problems trying to get
I have been having some problems trying to get my PHP running. When I
I'm trying to get a regexp to solve the next problem: I have some
I'm having some problems trying to perform a query. I have two tables, one
I have been trying to learn Erlang and have been running into some problems
I'm trying to build firefox but I'm having some problems. I currently have Visual
I have this query, which is giving me some problems... I am trying to
I have some problem in my JDBC code. I am trying to connect through
I'm have horrendous problems trying to get a JOGL program compiling using Netbeans 6.9.

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.