We all know that you can use it 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>?);
The meaning of this sentence is to remove the Teststu collection from a persistent team object, and to filter out records of age greater than the execution data
We can set the 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 again in the HQL. The variable placeholder appears, i.e.
Query query=session.createquery ("from Teststu s where s.team=?") and S.age>:age);
In this way, when setting the parameters, an exception will appear as follows:
Cannot define positional parameter after any named parameters has been defined [from Search.filter.TestStu s where s.team =:team and S.age>?]