But now it will replace all students, when I will enter school.students, I want to manually set the top 5 students, Then if you need 5-10, so
How do we customize delayed crawling in this way?
There are many students in the school
The students have nothing to do with the school
class Book {
...
static mapping = {
batchSize 10
}
}
See the Grails documentation.
Edit
You can use the query to create one Simple service instead of calling School.students
class SchoolService{
def getLastStudents(School school, int max, int offset){
// (Not tested but should be something like this)
def query = "select student from School school join school.students student where school=:school"
def students = School.executeQuery(query , [school: school], [max: max, offset: offset]) }
}
Then call schoolService.getLastStudents(school,10,0) as an example to get The last 10 students.
You can read all the information about the Gorm standard in the official documentation.
I have a course called School, It has a lot of students, so now when I use School.read (read) to read the school instance, I don’t want all the students to be taken out eagerly, so I changed the laziness of the acquisition strategy,
p>
But now it will replace all students, when I will enter school.stude nts, I want to manually set the top 5 students, and then 5-10 if needed, so
How do we customize delayed crawling in this way?
There are many students in the school
The students have nothing to do with the school
You can use batchSize to customize the delay Number of results obtained during loading:
class Book {
…
static mapping = {
batchSize 10
}
}
See the Grails documentation.
Edit
You can use a query to create a simple service instead of calling School.students
p>
class SchoolService{
def getLastStudents(School school, int max, int offset){
// (Not tested but should be something like this)
def query = "select student from School school join school.students student where school=:school"
def students = School.executeQuery(query, [school: school], [max: max, offset: offset]) }
}
Then call schoolService.getLastStudents(school,10,0) as an example to get the last 10 students.
You can read all about the Gorm standard in the official documentation.