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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:19:37+00:00 2026-05-12T11:19:37+00:00

I have a Hibernate mapping that looks something like this: <class name=MyEntity> <set name=scalarSet

  • 0

I have a Hibernate mapping that looks something like this:

<class name="MyEntity">
  <set name="scalarSet" table="(select fk, scalar_value from other_table)">
    <key column="fk"/>
    <property column="scalar_value" type="long"/>
  </set>
</class

Given this, how do I query such that a value of MyEntity.scalarSet (which is Set) is in a another collection.

Something like:

criteria.add(Restrictions.in("scalarSet", targetList));

[edit]
I’ve also tried Restriction.sqlRestriction(..). The sql query that I used is something like this:

"1 == (select fk, scalar_value from other_table where fk = {alias}.id and scalar_value in ({expanding?})"

Wherein ‘{expanding?}’ is replaced by comma-separated question marks (depending on targetList.size()).

But I’m just getting a

Caused by: org.hibernate.MappingException: collection was not an association: MyEntity.scalarSet

  • 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-12T11:19:37+00:00Added an answer on May 12, 2026 at 11:19 am

    Your set is a collection, not an association mapping – there are subtle but important differences. Using Hibernate’s Query API for collections is currently not supported.

    You need to either use HQL, or use a one-to-many association mapping by creating an entity with Long property, for example:

    public class Scalar {
      private Long value;
      public Long getValue() { .... }
      public void setValue(....) { ....}
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a hibernate mapping as follows: <hibernate-mapping> <class name=kochman.elie.data.types.InvoiceTVO table=INVOICE> <id name=id column=ID>
I have the following mapping: <hibernate-mapping package=server.modules.stats.data> <class name=User table=user> <id name=id> <generator class=native></generator>
Lets say I have the following mapping: <hibernate-mapping package=mypackage> <class name=User table=user> <id name=id
I'm trying to build an object that looks something like this: public class MyObject
I am creating a Fluent N hibernate subclass mapping that currently looks something like
Using NHibernate.Mapping.Attributes, I have a entity class with something like: [Class] public class EntityA
This is JavaScript regex. regex = /(http:\/\/[^\s]*)/g; text = I have http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd and I
I am using Hibernate to do mapping. One of my classes have a set
I have a parent-/child relationship of folders, which looks like this: A folder can
We have POCO, something like: public class Person { public Guid PersonID { get;

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.