This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one 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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Persistence message" Watch "Persistence message" New topic
Author

Persistence message

Jorge Coll
Greenhorn

Joined: Sep 02, 2011
Posts: 8
Hi,


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.


    Thanks,
    Jorge
    kumar naresh
    Ranch Hand

    Joined: Mar 12, 2011
    Posts: 119
        
        1
    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 |
    http://sceacertification.blogspot.in/2011_12_01_archive.html
    Jorge Coll
    Greenhorn

    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: http://aspose.com/file-tools
     
    subject: Persistence message