Does polymorphism belong to many for many cards in the grail?

So, I know that this is possible with the help of a superclass, however this greatly limits flexibility. So now my question is, can I use the interface? Something ala.

interface Taggable {
  /*Adds tag(s) and returns a list of currently set tags*/
  List<String> addTags(String ... tag)
  /*Removes tag(s) and returns a list of currently set tags*/
  List<String> removeTags(String ... tag)
}

class User implements Taggable {
  String username
  static hasMany = [tags:Tag]
}

class Tag {
  String name

  static hasMany = [references:Taggable]
  static belongsTo = Taggable

  static constraints = {
    name(nullable: false, blank: false, unique: true)
  }
}

I'm interested in a link to an object that has the following tag. However, this object cannot propagate a particular class. That's why they are wondering if this can be done using the interface.

So can this be done?

+3
source share
1 answer

Hibernate - . . , Grails - annotations XML.

: :

Taggable Tag.References .

  • , - , , Hibernate/Gorm class, db.

  • Taggable - Taggable part to Taggable , 1:1 - Hibernate.

BTW class - .

2: , , , :

  • Taggable hasMany=[tags:Tag];
  • , - .
+4

All Articles