0

I have two entites Parent and Child with OneToMany relationship in Hibernate, Parent has many Childs, I want to check if the Parent has Childs or not

I used these conditions and they not working

if (parent.getChilds().size() == 0)

and

if (parent.getChilds.isEmpty())
Spartan
  • 1,167
  • 4
  • 20
  • 40

1 Answers1

0

Those are equivalent. If you look at source of, for example, ArrayList#isEmpty() you'll find

public boolean isEmpty() {
    return size == 0;
}
Predrag Maric
  • 23,938
  • 5
  • 52
  • 68