Hibernate Exception: @OneToMany or @ManyToMany tar

2019-08-27 17:15发布

I have a MessengerData class which contains a list of resources. This is an example of the structure that I want to have:

 "messengerData":{  
  "fr":{  
        "messengerType":"ImageCategoryTitle",
        "imageURL":"https://assets.pernod-ricard.com/uk/media_images/test.jpg",
        "clickURL":"http://perdu.com",
        "videoURL":"",
        "brickSize":80,
        "textDatas":{  
           "category":{  
              "color":"#000000",
              "fontSize":14,
              "textValue":"Texte de cat\u00e9gorie en fran\u00e7ais"
           },
           "title":{  
              "color":"#D66060",
              "fontSize":12,
              "textValue":"Titre en fr, peut aussi avoir des markusp genre <b>bold</b> <i>italique</i> <s>strike</s> <u>underline</u>"
           }
        }
     },
  "en": 
     {  
        "messengerType":"ImageCategoryTitle",
        "imageURL":"https://assets.pernod-ricard.com/uk/media_images/test.jpg",
        "clickURL":"http://perdu.com",
        "videoURL":"",
        "brickSize":80,
        "textDatas":{  
           "category":{  
              "color":"#000000",
              "fontSize":14,
              "textValue":"Category text can be sized differently"
           },
           "title":{  
              "color":"#D66060",
              "fontSize":12,
              "textValue":"Title color may change"
           }
        }
     }

}

This is how I define my Entity :

@Entity
public class MessengerData
{
@Basic
@Id
@GeneratedValue(generator = "notification-system-uuid")
@GenericGenerator(name = "notification-system-uuid", strategy = "uuid")
private String messengerDataId;

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "idResource")
private Map<String, List<Resource>> resources;

My problem is that I am getting the exception described within the title of this post. I used a map because that I want to respect the json format.

Could someone help me with this ?

0条回答
登录 后发表回答