<commit_before>package org.innovateuk.ifs.organisation.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.innovateuk.ifs.address.domain.Address;
import org.innovateuk.ifs.address.domain.AddressType;
import org.innovateuk.ifs.user.domain.Organisation;

import javax.persistence.*;
import javax.validation.Valid;

/**
 * Resource object to store the address details, from the company, from the company house api.
 */
@Entity
@Table(uniqueConstraints = { @UniqueConstraint( columnNames = { "organisation_id", "address_id" } ) } )
public class OrganisationAddress {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @ManyToOne(fetch = FetchType.LAZY)
    private Organisation organisation;
    @Valid
    @ManyToOne(cascade = CascadeType.ALL)
    private Address address;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="address_type_id", referencedColumnName="id")
    private AddressType addressType;

    public OrganisationAddress(Organisation organisation, Address address, AddressType addressType) {
        this.organisation = organisation;
        this.address = address;
        this.addressType = addressType;
    }

    public OrganisationAddress() {
    	// no-arg constructor
    }

    @JsonIgnore
    public Organisation getOrganisation() {
        return organisation;
    }

    public void setOrganisation(Organisation organisation) {
        this.organisation = organisation;<commit_msg>IFS-2977: Fix data integrity violation on update project address.<commit_after>package org.innovateuk.ifs.organisation.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.innovateuk.ifs.address.domain.Address;
import org.innovateuk.ifs.address.domain.AddressType;
import org.innovateuk.ifs.user.domain.Organisation;

import javax.persistence.*;
import javax.validation.Valid;

/**
 * Resource object to store the address details, from the company, from the company house api.
 */
@Entity
@Table(uniqueConstraints = { @UniqueConstraint( columnNames = { "organisation_id", "address_id" } ) } )
public class OrganisationAddress {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @ManyToOne(fetch = FetchType.LAZY)
    private Organisation organisation;
    @Valid
    @ManyToOne(cascade = {CascadeType.DETACH, CascadeType.MERGE, CascadeType.REFRESH, CascadeType.PERSIST})
    private Address address;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="address_type_id", referencedColumnName="id")
    private AddressType addressType;

    public OrganisationAddress(Organisation organisation, Address address, AddressType addressType) {
        this.organisation = organisation;
        this.address = address;
        this.addressType = addressType;
    }

    public OrganisationAddress() {
    	// no-arg constructor
    }

    @JsonIgnore
    public Organisation getOrganisation() {
        return organisation;
    }

    public void setOrganisation(Organisation organisation) {
        this.organisation = organisation;
{'fraction_non_alphanumeric': 0.09242325277596342, 'fraction_numerical': 0.0013063357282821686, 'mean_word_length': 4.113522537562605, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1700823', 'n_tokens_mistral': 871, 'n_tokens_neox': 839, 'n_words': 192}