Announcement Announcement Module
Collapse
No announcement yet.
disable cascade for many-to-one Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • disable cascade for many-to-one

    I have two class, Campaign and Country. My country table has fixed data and should not be changed in program.
    Campaign has many-to-one relation to Country. I do not want to have cascade update/delete on this relations. And there is no cascade set up on Campaign class. But it still update the country table. How could I disable that?
    Here is part of my configuration:
    in Campaign


    @ManyToOne
    @JoinColumn(name="countryId", referenceColName="countryId")
    private Country country;

    Inside Country class, there is no any configuration and properties related to Campaign.

    Thanks a lot.

  • #2
    Hi, review the configuration using javax.persistence.CascadeType:

    Code:
    @ManyToOne(cascade=CascadeType.ALL)
    @JoinColumn(name="countryId", referenceColName="countryId")
    private Country country;

    Comment


    • #3
      I do not want to have cascade. Even I did not give cascade=CascadeType.ALL, it still modify country information. I like to keep country information unchanged when I change Campaign object.
      Thanks.

      Comment

      Working...
      X