- CascadeType.MERGE is basicly an UPDATE statement, it needs to be REFRESH (from database to local entity object)
- Fetch strategy EAGER is default, no need to specify it
- updated jar(s)
* User owner instance
*/
@JoinColumn (name = "company_user_id", nullable = false, updatable = false)
- @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.MERGE, optional = false)
+ @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false)
private User contactUserOwner;
/**
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
-import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
* User owner instance
*/
@JoinColumn (name = "company_user_id", nullable = false, updatable = false)
- @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.MERGE, optional = false)
+ @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false)
private User basicUserOwner;
/**
* Company's main fax numbers: +ccxxxxxxxxxx
*/
@JoinColumn (name = "company_fax_number_id")
- @OneToOne (targetEntity = FaxNumber.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
+ @OneToOne (targetEntity = FaxNumber.class, cascade = CascadeType.ALL)
private DialableFaxNumber companyFaxNumber;
/**
* Company's main phone number: +ccxxxxxxxxxx
*/
@JoinColumn (name = "company_phone_number_id")
- @OneToOne (targetEntity = LandLineNumber.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
+ @OneToOne (targetEntity = LandLineNumber.class, cascade = CascadeType.ALL)
private DialableLandLineNumber companyPhoneNumber;
/**
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
-import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
* Branch office's country code
*/
@JoinColumn (name = "branch_country_id", nullable = false)
- @OneToOne (targetEntity = CountryData.class, cascade = CascadeType.MERGE, optional = false, fetch = FetchType.EAGER)
+ @OneToOne (targetEntity = CountryData.class, cascade = CascadeType.REFRESH, optional = false)
private Country branchCountry;
/**
* User owner instance
*/
@JoinColumn (name = "branch_user_id", nullable = false, updatable = false)
- @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.MERGE, optional = false)
+ @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false)
private User branchUserOwner;
/**
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
-import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
* Connection to company contact
*/
@JoinColumn (name = "department_company_id", nullable = false, updatable = false)
- @ManyToOne (targetEntity = CompanyContact.class, cascade = CascadeType.ALL, optional = false, fetch = FetchType.EAGER)
+ @ManyToOne (targetEntity = CompanyContact.class, cascade = CascadeType.ALL, optional = false)
private BusinessContact departmentCompany;
/**
* Department lead employee
*/
@JoinColumn (name = "department_lead_id", nullable = false)
- @OneToOne (targetEntity = CompanyEmployee.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
+ @OneToOne (targetEntity = CompanyEmployee.class, cascade = CascadeType.ALL)
private Employee departmentLead;
/**
* User owner instance
*/
@JoinColumn (name = "department_user_id", nullable = false, updatable = false)
- @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.MERGE, optional = false)
+ @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false)
private User departmentUserOwner;
@Override
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
-import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
* Employee's personal data
*/
@JoinColumn (name = "employee_personal_data_id", nullable = false, updatable = false)
- @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.ALL, optional = false, fetch = FetchType.EAGER)
+ @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.ALL, optional = false)
private Contact employeePersonalData;
/**
* Employee's position (example: CEO)
*/
@JoinColumn (name = "employee_position_id")
- @OneToOne (targetEntity = EmployeePosition.class, cascade = CascadeType.MERGE, fetch = FetchType.EAGER)
+ @OneToOne (targetEntity = EmployeePosition.class, cascade = CascadeType.REFRESH)
private JobPosition employeePosition;
/**
* User owner instance
*/
@JoinColumn (name = "employee_user_id", nullable = false, updatable = false)
- @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.MERGE, optional = false)
+ @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false)
private User employeeUserOwner;
@Override
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
-import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
* Headquarter's country code
*/
@JoinColumn (name = "headquarters_country_id", nullable = false)
- @OneToOne (targetEntity = CountryData.class, cascade = CascadeType.MERGE, optional = false, fetch = FetchType.EAGER)
+ @OneToOne (targetEntity = CountryData.class, cascade = CascadeType.REFRESH, optional = false)
private Country headquartersCountry;
/**
* User owner instance
*/
@JoinColumn (name = "headquarters_user_id", nullable = false, updatable = false)
- @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.MERGE, optional = false)
+ @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false)
private User headquartersUserOwner;
/**
* Logo uploader user instance
*/
@JoinColumn (name = "logo_uploader_id", nullable = false, updatable = false)
- @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.MERGE, optional = false)
+ @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false)
private User logoUploader;
@Override