Use Map as property of model in Play

前端 未结 3 1035
日久生厌
日久生厌 2021-02-04 17:33

I\'m trying to use a Map as a type for one of my models properties. Let\'s take these two classes for example:

@Entity
public class Foo extends Model {

    @One         


        
相关标签:
3条回答
  • 2021-02-04 18:15

    Remove the:

    @MapKey(name = "name")
    
    0 讨论(0)
  • I tryed your code today and it worked without problems. Which play version do you use? I use 1.2.3.

    Maybe the plugin association solves that problem, because that is what I'm using in background. Please let me know if an upgrade helped you.

    Follows standard play module installation procedure:

    play install associations
    

    Add the following line to your dependencies.yml replacing 1.0 with desired version:

    require:
        - play -> associations 1.0
    
    0 讨论(0)
  • 2021-02-04 18:22

    I had the same issue in v1.2.3 with Fixtures. Strangely if I didn't define a fixture below the one with the bi-directional Map OneToMany relationship there wasn't a problem. I also had a problem in one of my controllers if I didn't setup the bi-directional relationship completely. It does seem to be directly related to using a Map in a bi-directional OneToMany relationship. I switched to a Set and the problem went away. In the end I managed to resolve the situation without reverting to a Set by upgrading to v1.2.4RC2. I had a quick look through the change list in v1.2.4RC2 but couldn't spot anything that directly mentioned fixing this issue but something must have been resolved.

    0 讨论(0)
提交回复
热议问题