related entities get persisted as null

I'm new to jpa and hibernate, I'm trying to persist a bean that have 2 relationships with two entities as I do so the the entity that I'm trying to save gets saved but the related entities don't, they stay null 1st class

@Entity
@Table(name = "MODIFICATION")
public class ModificationBE extends AbstractBE implements Serializable {

    /**
     *
     */

    private static final long serialVersionUID = 5862456626257704084L;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "modification_seq")
    @SequenceGenerator(name = "modification_seq", sequenceName = "modification_sequence", allocationSize = 1)
    @Column(name = "ID", unique = true, nullable = false)
    private Long idModification;

    @Relation(RelationType.ENTITY)
    @OneToMany(cascade = CascadeType.MERGE, fetch = FetchType.EAGER, orphanRemoval = false)
    @JoinColumn(name = "ID_Profils")
    private List profils;

    @Relation(RelationType.ENTITY)
    @OneToOne(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
    @JoinColumn(name = "ID_Utiisateur")
    private UtilisateurBE user;

second class

@Entity
@Table(name = "Utilisateur")
public class UtilisateurBE extends AbstractBE implements Serializable {

    /**
     *
     */
    private static final long serialVersionUID = 5192421474902029299L;
    @Id
    @Column(name = "ID", unique = true, nullable = false)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "user_seq")
    @SequenceGenerator(name = "user_seq", sequenceName = "user_sequence", allocationSize = 1)
    private Long idUtilisateur;
    @Column(name = "nom")
    private String nom;
    @Column(name = "prenom")
    private String prenom;
    @Column(name = "email")
    private String email;
    @Enumerated(EnumType.STRING)
    @Column(name = "type")
    TypeUtilisateur typeUser;
    @OneToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
    private ModificationBE modification;

3rd Class/entity

@Entity
@Table(name = "PROFIL")
public class ProfilBE extends AbstractBE implements Serializable {

    /**
     *
     */
    private static final long serialVersionUID = -4017244348063720915L;
    @Id
    @Column(name = "ID", unique = true, nullable = false)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "profil_seq")
    @SequenceGenerator(name = "profil_seq", sequenceName = "profil_sequence", allocationSize = 1)
    private Long idProfil;
    @Column(name = "nom")
    private String nom;
    @Column(name = "prenom")
    private String prenom;
    @Column(name = "email")
    private String email;
    @Enumerated(EnumType.STRING)
    @Column(name = "type")
    private TypeProfil typeProfil;
    @ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.DETACH)
    @JoinColumn(name = "ID_Groups")
    private List groups;
    @Column(name = "status")
    private boolean status;

I try to post this

        {
    "idModification": 1,
    "profils": [
    {
    "idProfil": 1,
    "nom": "toto",
    "prenom": "ElGrande",
    "email": "elGrande.toto@vero.com",
    "typeProfil": "ASSOCIE",
    "groups": [
    {
    "id": 2936,
    "name": "Suivi Performance Entrepôt",
    "centrale": "NORD-OUEST",
    "specGroupe": null,
    "privilege": "CPI et développeur"
    },
    {
    "id": 3008,
    "name": "SIDO",
    "centrale": "NORD-OUEST",
    "specGroupe": "Appro",
    "privilege": "Expert"
    }
    ],
    "status": true
    },
    {
    "idProfil": 1,
    "nom": "tata",
    "prenom": "ElGrande",
    "email": "elGrande.tata@vero.com",
    "typeProfil": "PDV",
    "groups": [
    {
    "name": "SIDO",
    "idGroup": 1
    },
    {
    "name": "SIDE",
    "idGroup": 2
    }
    ],
    "status": "true"
    }
    ],
    "user": {
    "nom": "Lemcirdi",
    "prenom": "Anas",
    "email": "anas.lemcirdi@haha.com",
    "typeUser": "SID",
    "id": "1"
    }
    }

but this

{
    "idModification": 1,
    "profils": null,
    "user": null
}

what gets saved to my database, I get no errors so it must be a mapping error. how can I fix it please.

链接地址: http://www.djcxy.com/p/90900.html

上一篇: Sublime Text可以用快捷方式在<li> foo </ li>内跳转?

下一篇: 相关实体将被保持为空