Many-To-Many model, how to generate the list?

H

hepower

Guest
hello everyone,

I have a many-to-many relation ship between table Teacher & table Student, details as below:

Code:
class Student {
    String name
    String age
    
    static hasMany = [teachers: Teacher]
    
    static constraints = {
    }
    
    static belongsTo = [Teacher]
    
    static mapping = {
    cache true
    }
}

package dbtest

class Teacher {

    String name
    String major
    
    static hasMany = [students: Student]
    
    static constraints = {
    }
    
    static mapping = {
    cache true
    }
}

we have 'students' and 'teachers' list in these 2 domain classes, my question is that , when I tried to generated the controller and views using 'generate-all' command, how to show the list information?
like when i click 1 specific student or teacher information in student->show or teacher->show, how can I see the students belongs to a specific teacher or the teachers which related to a student?
I mean the 'students' and 'teachers' seems empty.

thanks.
 
H

hepower

Guest
hello everyone,

I have a many-to-many relation ship between table Teacher & table Student, details as below:

Code:
class Student {
    String name
    String age
    
    static hasMany = [teachers: Teacher]
    
    static constraints = {
    }
    
    static belongsTo = [Teacher]
    
    static mapping = {
    cache true
    }
}

package dbtest

class Teacher {

    String name
    String major
    
    static hasMany = [students: Student]
    
    static constraints = {
    }
    
    static mapping = {
    cache true
    }
}

we have 'students' and 'teachers' list in these 2 domain classes, my question is that , when I tried to generated the controller and views using 'generate-all' command, how to show the list information?
like when i click 1 specific student or teacher information in student->show or teacher->show, how can I see the students belongs to a specific teacher or the teachers which related to a student?
I mean the 'students' and 'teachers' seems empty.

thanks.


the problem has been solved.
it is the view error, but the list has been generated.
 
H

hepower

Guest
problem is gone.

hello everyone,

I have a many-to-many relation ship between table Teacher & table Student, details as below:

Code:
class Student {
    String name
    String age
    
    static hasMany = [teachers: Teacher]
    
    static constraints = {
    }
    
    static belongsTo = [Teacher]
    
    static mapping = {
    cache true
    }
}

package dbtest

class Teacher {

    String name
    String major
    
    static hasMany = [students: Student]
    
    static constraints = {
    }
    
    static mapping = {
    cache true
    }
}

we have 'students' and 'teachers' list in these 2 domain classes, my question is that , when I tried to generated the controller and views using 'generate-all' command, how to show the list information?
like when i click 1 specific student or teacher information in student->show or teacher->show, how can I see the students belongs to a specific teacher or the teachers which related to a student?
I mean the 'students' and 'teachers' seems empty.

thanks.

problem is solved , it is the view problem not the GORM issue.
 
Top