Org.hibernate.TransientObjectException if any multi-valued fields are null (or not selected on the form)

I am using jpa with play framework. I have a JobseekerDetails object

@Entity
public class JobseekerDetails {

    @Id
    @Column(name = "jobseekerDetails_id", nullable = false)
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long jobseekerDetails_id;

    @ManyToOne
    @JoinColumn(name = "basicEducation_id")
    private JobseekerFormBasicEducation basicEducation;

     @ManyToOne
    @JoinColumn(name = "masterEducation_id")
    private JobseekerFormMasterEducation masterEducation;

    @ManyToOne
    @JoinColumn(name = "doctrateEducation_id")
    private JobseekerFormDoctrateEducation doctrateEducation;

    @ElementCollection
    private List<String> certificateName =new ArrayList<String>();

    @Column(length = 3000)
    private String resume;

    private Long experience;

    private String skills;

    private String resumePath;

    @ManyToOne
    @JoinColumn(name = "industry_id")
    private JobseekerFormIndustry industry;

     @ManyToOne
    @JoinColumn(name = "functionalArea_id")
    private JobseekerFormFunctionalArea functionalArea;

}

which are many-to-one related to other objects such as JobseekerFormFunctionalArea , JobseekerFormIndustry , etc. These objects have a fixed value that is already stored in the database.

When JobseekerDetails is saved, all its data must be stored with the corresponding identifiers of many of them, but not stored in Entity JobseekerFormFunctionalArea and JobseekerFormIndustry, as they are predefined

, ( ) JobseekerDetails, , - - . , fuctionalArea_id

org.hibernate.TransientObjectException:object references an unsaved transient instance - save the transient instance before flushing

, , - , ,

jpa nullable = true, this happend

, . Cacade Merge, .

nullable = true,

cascade = CascadeType.ALL cascade = CascadeType.PERSIST

PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist:

+4
1

- " " , . , :

jobseekerDetails.basicEducation = new JobseekerFormBasicEducation ()

TransientObjectException

,

jobseekerDetails.basicEducation=null 

.

0

All Articles