This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Persistence message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Persistence message" Watch "Persistence message" New topic

Persistence message

Jorge Coll

Joined: Sep 02, 2011
Posts: 8

I'm not sure about what's the correct message to invoke the persistence of an entity in my sequence diagrams. I'm using the Cade/Sheil model in which the persistence is realized by an invocation message "persist" to EntityManager (JPA).

My questions are...
  • If the object (maybe) already persisted... I must use another message like "merge"?
  • Can I use "persist" as a generic method for new or already existing objects?
  • I must use notes in these cases?
  • I must use conditional structures in this cases?

  • Maybe one item could answer the others.

    kumar naresh
    Ranch Hand

    Joined: Mar 12, 2011
    Posts: 120
    Check with the object Id with that of database Id if it is available you will get entity object and on the entity object use merge, if it is not available create the object, send it as persists to create a new.

    OCMJEA 5 |
    Jorge Coll

    Joined: Sep 02, 2011
    Posts: 8
    Thanks Kumar!

    I know that these steps are programatically corrects without any doubt but I'm thinking that put all this logic together in the sequence diagrams could be a little excesive.

    Mr. Cade tell us: "Another common mistake (in all diagrams, not just the class diagram) is to focus on the 'how' and not the 'what'".

    I try to put this kind of programatic persistence logic on my sequence diagrams and the result looks very 'dirty'.

    I don't know if will be possible to put something like "persist/merge" over the sequence diagrams arrows and left the low level coding details outside.
    I agree. Here's the link:
    subject: Persistence message
    It's not a secret anymore!