0

recently i was going through an article in hibernate.I have seen this please enlighten me on this

public Criteria createCriteria(String associationPath, String alias, int joinType) {
    return new Subcriteria( this, associationPath, alias, joinType );//return new object
}


public Criteria createAlias(String associationPath, String alias, int joinType) {
    new Subcriteria( this, associationPath, alias, joinType );
    return this;//return this
}
Shabbir Dhangot
  • 8,954
  • 10
  • 58
  • 80
ThinkTank
  • 1,737
  • 5
  • 22
  • 36

1 Answers1

1

First example will return a new instance of the type Subcriteria. Second one will return current instance. See about this keyword in java here and discussion is here.

So the difference is simple.

  1. New
  2. Existing (current)

The link you provided in the comment clearly answers the question. Have a look again.

Community
  • 1
  • 1
Nabin
  • 11,216
  • 8
  • 63
  • 98