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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:02:31+00:00 2026-05-28T06:02:31+00:00

I have a class A : @Entity public class A { … @ManyToMany private

  • 0

I have a class A :

@Entity
public class A {
  ...
  @ManyToMany
  private Set<Ref> refs = new HashSet<Ref>();
  ...
}

And a class Ref :

@Entity
public class Ref {
 // no link to A
}

I want to delete A and A_Ref but not Ref, but i get a org.hibernate.exception.ConstraintViolationException

Is there a simple way to do it or should i explicitely create a A_Ref class ?

Thanks

Edit :
I was attempting to delete my list of A directly in hql. I did it in object (broke the relations) and it worked (cascade + orphan deletion).

  • 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-28T06:02:31+00:00Added an answer on May 28, 2026 at 6:02 am

    I am not sure, if I got you right, but from what I understood my first guess is, that you havent used all necessary annotations to make sure, that hibernate will automatically remove necessary references in Ref by itself.

    Within a manyToMany relation, you can use joinTables and cascadetypes to make sure, that hibernate knows where to delete all necessary relations by itself without creating an own domainObject for it.

    There are plenty of nice guides how to manage it. On first view the guide from mkyong looks pretty good. Note: He annotated getters instead of variable declarations! (which is just a question of taste).

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

Sidebar

Related Questions

Suppose I have public class Product: Entity { public IList<Item> Items { get; set;
Say I have this class: @Entity @Table(name=PICTURE) public class Picture{ private String category1, category2;
I have following class ( entity ) @Entity public class Magazine { private int
I have an abstract entity: public abstract class Entity extends JPanel implements FocusListener And
I have an entity similar to the below: public class Entity { public List<DateItem>
Let's say I have the typical entity Car class Car : Entity { public
Imagine I have an entity: public class MyObject { public string Name { get;
Let's say I have this entity (for Hibernate): @Entity public class Person { @Id
A have two entities. For example timing settings and orders. @Entity public class TimingSettings{
I have the following classes in my Model: public abstract class Entity : IEntity

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.