0

I have a Hibernate query with Criteria.

What I would like to do is (just for one query) tell hibernate to ignore an existing @ManyToOne annotation.

that is because hibernate creates and Left join on other tables. I could figure it how to do it.

I have found this 2 links which didn't solve my problem:

Hibernate: How to remove an entity to which none refers to anymore in ManyToOne?

What is the difference between DELETE_ORPHAN and DELETE?

Community
  • 1
  • 1
2Big2BeSmall
  • 1,348
  • 3
  • 20
  • 40

1 Answers1

1

If you have such mapping:

//Parent
public class A {
    ...
}

//Child
public class B {
   private A parent; //Many to one
   ...
}

Please try something like this:

Criteria q = ....;
q.setFetchMode("parent", FetchMode.SELECT);
....
Dekart
  • 141
  • 1
  • 8