Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>- Where the activities of Customer are getting saved ?</strong></p> <p>They are not getting saved as "activities of customer" anywhere in the DB.When the activities of a customer are needed, they are loaded together with the customer using a join query on the <code>customer_id</code> column, or they are loaded later (lazy-loading) using a separate query that filters the <code>customer_id</code> column.</p> <p><strong>- How the update and delete operation of both of the entities will effect each other?</strong></p> <p>A delete of an activity will not affect the customer, but next time its activities are loaded, the deleted activity will not be part of the collection anymore.</p> <p>How the delete of a customer activities can be defined using the cascade attribute on the <code>@ManyToOne</code>, for example :</p> <p><code>@OneToMany(mappedBy = "customer", cascade = CascadeType.REMOVE)</code></p> <p>Basically, the desired behavior depends on if an activity can exist on its own without a customer : if yes, then the customer can be deleted, and the <code>customer_id</code> field can be set to null on the activity table. Otherwise the activities belonging to a customer will be 'cascade-deleted'. Or a customer just can0t be deleted before one has removed all its activities first.</p> <p><strong>- Is it the right way to create @OneToMany and @ManyToOne relationship?</strong></p> <p>Yes, it is correct.</p> <p><strong>- Can I add column name on activities?</strong></p> <p>No, it wouldn't make any sense. A column could only contain one ID, and activities is a collection.</p> <p>I hope this helps.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload