I also think so, but it does not work. I added a mapping from address to
company, but it makes no difference.

In company:

  @OneToOne
  @JoinColumn(name = "main_adres_id")
  public Address getAddress() {
    return address;
  }

  public void setAddress(Address address) {
    this.address = address;
  }

In address:

  @OneToOne(mappedBy = "address")
  public Company getCompany() {
    return company;
  }

  public void setCompany(Company company) {
    this.company = company;
  }

In action:

  public String save() throws Exception {
    if (cancel != null) {
      return "cancel";
    }

    if (delete != null) {
      return delete();
    }

    boolean isNew = (company.getId() == null);

    //save the address first

    companyManager.save(company);
    ...

When saving I get:

Data Access Failure

object references an unsaved transient instance - save the transient
instance before flushing: com.hw.app.model.Address; nested exception is
org.hibernate.TransientObjectException: object references an unsaved
transient instance - save the transient instance before flushing:
com.hw.app.model.Address 

Very strange. First I thought it was because address did not have a mapping
back to company. So I added it, but no effect.

Any ideas?
-- 
View this message in context: 
http://www.nabble.com/saving-related-objects-tp25440670s2369p25444770.html
Sent from the AppFuse - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
For additional commands, e-mail: users-h...@appfuse.dev.java.net

Reply via email to