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

  • Home
  • SEARCH
  • 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 312519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:01:25+00:00 2026-05-12T08:01:25+00:00

And if so, what is the syntax? Assume that I want an instance of

  • 0

And if so, what is the syntax?

Assume that I want an instance of Foo to be unassociated from all instances of Bar:
In SQL it would simply be:

delete from FOO_BAR_MAPPING
where FOO_ID = ?

In HQL, I assumed it would be something like:

delete from Bar.foos foos
where foos.id = :id

(where foos is a mapped collection of Foo)

But appears to be wrong, giving:

org.hibernate.hql.ast.QuerySyntaxException: Bar.foos is not mapped

Is this even possible with HQL?

  • 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-12T08:01:25+00:00Added an answer on May 12, 2026 at 8:01 am

    To answer your specific question, no, as far as I’m aware it’s not possible with HQL.

    I think you’re mixing SQL and HQL a little bit here. In SQL, you indeed “delete” records, and of course hibernate will ultimately do that as well. However Hibernate/HQL is designed from an object-oriented mindset, so “delete” in this context means you are deleting objects, not associations. Typically you’d do something like follows:

    Foo f = session.get(Foo.class, id);
    f.getBars().clear();
    session.merge(f);
    

    This retrieves the object by the id you specified, and removes all Bar associations by clearing it’s collection. Obviously you have to have the Foo-Bars association mapped in the proper direction for this to work.

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

Sidebar

Related Questions

Does the SQL syntax differ in any way for SQL Plus and apex.oracle.com From
Assume a custom control in Silverlight that has three TextBlock elements named Left, Middle
I want to overload the assignment operator for types like int, long etc. That
I have a class library that wraps the command line client for Mercurial. My
http://en.wikipedia.org/wiki/Upsert Insert Update stored proc on SQL Server Is there some clever way to
Is it possible, and if so, how can I create a signal/slot in Qt
I ran into this problem while developing in Objective-C for iOS, but this should
I really need help getting this query right. I can't share actual table and
i was asked a few java interview questions which i had no idea how
I'm using ASP.NET MVC2 and C#, but this question applies to ASP.NET in general.

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.