What do REFRESH and MERGE mean in terms of databases?

JPA Annotation Meaning for Many to Many relationships:

  • ALL – all possible cascading operations performed on the source entity are cascaded to the target of the association.
  • MERGE – if the source entity is merged, the merge is cascaded to the target of the association.
  • PERSIST – if the source entity is persisted, the persist is cascaded to the target of the association.
  • REFRESH – if the source entity is refreshed, the refresh is cascaded to the target of the association.
  • REMOVE – if the source entity is removed, the target of the association is also removed.

I myself see them this way (more readable):

  • MERGE – for existing objects, to merge the existing data in the table with the data in my object. (sync to database)
  • PERSIST – is create new records from object in the database.
  • REFRESH – is to refresh the data in the object. Perhaps there was a change on the database which needs to be synced. (sync from database)
  • REMOVE – is, well, delete.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)