My domain objects are roughly like:
@Entity
public class Customer{
@Id
private String id;
private String name;
@OneToMany(cascade=CascadeType.ALL)
private List<Account> accountList;
}
@Entity
public class Account{
@Id
private String id;
private String name;
@OneToMany
private List<Service> serviceList;
@ManyToOne(cascade=CascadeType.ALL)
@JoinColumn(nullable=false)
private Customer customer;
}
@Entity
public class Service{
@Id
private String id;
private String name;
@ManyToOne
@JoinColumn(nullable=false)
private Account account;
}
I have a transactional Spring service. I want to return an Account instance to fronthand but I don't want to send Customer and Service List informations because of bandwith issues.
When I do: account.setServiceList(null); It gives no error but after a while it deletes all my service list.
When I do: account.setCustomer(null); It says customer_id of account cannot be null.
I just want to return a transient instance without a validation. How can I handle this.