Results 1 to 3 of 3

Thread: disable cascade for many-to-one

  1. #1
    Join Date
    Jan 2005
    Posts
    14

    Default 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. #2
    Join Date
    May 2011
    Location
    Madrid (Spain)
    Posts
    101

    Default

    Hi, review the configuration using javax.persistence.CascadeType:

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

  3. #3
    Join Date
    Jan 2005
    Posts
    14

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •