Pergunta

I have a table called person with primary key as id and in the same table I have a foreign key as master_id that references id (primry key) in the same table person. How do I create my domain class in grails for person. ?

Table Person

 Integer person_id PK auto_increment
 String name
 String address
 String city
 Integer  FK master_id references Person(person_id) 
Foi útil?

Solução

Just create a field of the appropriate type with a name of master:

class Person {
     Person master
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top