class File {
String name
File parent;
static belongsTo =[parent:File ]
static hasMany = [childrens:File];
static mapping = {
table 'Info_File'
id(generator:'sequence', params: [sequence: 'seq_file'])
parent:[lazy:"true",cascade:"none"]
children joinTable:[name:'children', key:'parent_Id', column:'Id',lazy:"true",inverse:"false",cascade:"none"]
}
static constraints = {
parent(nullable:true)
}
}
maintenant je veux tout le fichier qui ID parent = 1 Comment puis-je faire?Question de Grails findAllBy lorsque la recherche de clé étrangère pour
i essayer d'utiliser
def fileList = File.findAllByParent(File.get(1L))
mais il envoie 2 sql, le 1er est d'obtenir les informations de fichier parent que je ne veux pas lui.
est-il un procédé tel que File.findAllByParentId (1L)
3x
grâce.
parent{eq('key', 1)}
//sql:from Info_File this_ left outer join Info_File parent_ali1_
//on this_.parent_id=parent_ali1_.id where (parent_ali1_.id=?)
mais je n'ai pas besoin de joindre la table. donc j'essayer
eq('parent.id',1L)
//it's what i need:
//from Info_File this_ where this_.parent_id=?
merci. > parent {eq ('clé', 1)} sql: à partir de Info_File this_ jointure externe gauche Fichier_d'information parent_ali1_ sur this_.parent_id = parent_ali1_.id où (parent_ali1_.id =?) mais je n'ai pas besoin de joindre la table. donc j'essaye eq ('parent.id', 1L), c'est ce dont j'ai besoin: de Info_File this_ où this_.parent_id =? – atian25