We all know that it can be used in HQL. OR: * * * the way to configure query parameters externally, such as:
Query query=session.createquery ("from Teststu s where S.team=:team and S.age>:age"); Or
Query query=session.createquery ("from Teststu s where s.team=?") and S.age>?);
From a persistent team object, take out the collection of Teststu it holds and filter out the records of age greater than the execution data
We can set parameters like this
Query.setparameter ("Team", Team,hibernate.entity (Testteam.class));
or use Query.setentity ("Team", team);
Query.setparameter ("Age", 15);
But we must not appear in the HQL again, the variable placeholder, that is,
Query query=session.createquery ("from Teststu s where s.team=?") and S.age>:age);
In this way, when you set the parameters, the exception appears as follows:
Cannot define positional parameter after no named parameters have been defined [from Search.filter.TestStu s where s.team =:team and S.age>?]