This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Should I have Entity Manager in the Sequence diagram Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Should I have Entity Manager in the Sequence diagram" Watch "Should I have Entity Manager in the Sequence diagram" New topic
Author

Should I have Entity Manager in the Sequence diagram

Luay Abdulraheem
Ranch Hand

Joined: May 18, 2011
Posts: 65
In most of my Sequence diagrams, the last object is the DAO. In some posts on the forum some people are saying that they have included the Entity Manager in their Sequence diagrams.

Question: 1) Adding the Entity Manager in Sequence diagrams means adding it in the Class diagram as well ?
2) Adding the Entity Manager in Sequence diagrams means adding the Entities in Sequence diagrams as well ?

SCJP, SCWCD, OCMJEA, OCEEJBD, OCEJPAD, TOGAF® 9 Certified, OCEJWSD
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30136
    
150

1) No. It is fine to keep the class diagrams to classes owned by your system.
2) It's up to you. I didn't because it was confusing. I ended with the entity manager.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Pratik Bhavsar
Greenhorn

Joined: Feb 04, 2009
Posts: 20
On the same lines, if I have a find operation, do I have to show the Query object on the sequence diagrams?

Please help.

Thank you.
Luay Abdulraheem
Ranch Hand

Joined: May 18, 2011
Posts: 65
Suppose I end with an Entity Manager, the DAO will send a message to Entity Manager, but will the Entity Manager send a reply message to DAO ? Because in Cade's example there is only a message but with no reply message from Entity Manager.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30136
    
150

Pratik: I wouldn't. We don't show Strings and ArrayLists and other built in objects in the sequence diagram.

Luay: He calls persist() which returns void. Most people use the return arrow anyway to show the method has completed, but this might be why. I've added it to the list of non-standard things in the Cade/Sheil solution.
Krzysztof Koziol
Ranch Hand

Joined: Nov 19, 2006
Posts: 133

Luay Abdulraheem wrote:Suppose I end with an Entity Manager, the DAO will send a message to Entity Manager, but will the Entity Manager send a reply message to DAO ? Because in Cade's example there is only a message but with no reply message from Entity Manager.


I think it makes sense only when EM perform search and will return some object or collection of objects. BTW, how to show when EM will call named query, should we put all calls in sequence diagram: EM.createNamedQuery().getResultList() ?

Is it really important to show EM on sequence diagram even when we have self-descriptive method in our DAO, let's say userDao.findUserByName(). Everybody knows that under the hood we need to call one of create*Query() on EM and then getSingleResult() or getResultList() on Query object.


SCJP 5.0, SCWCD 5.0, SCBCD 5.0, SCEA/OCMJEA 5.0
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1076
    
  10

I don't think you need to show to the detail of the 'named query'. I have a similar 'findBy' method and I just showed it going to EntityManager with a 'query' action name - to just indicate that entitymanager is used to query the database.


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
Krzysztof Koziol
Ranch Hand

Joined: Nov 19, 2006
Posts: 133

Ranganathan Kaliyur Mannar wrote:I don't think you need to show to the detail of the 'named query'. I have a similar 'findBy' method and I just showed it going to EntityManager with a 'query' action name - to just indicate that entitymanager is used to query the database.


Have you got DAO before EM call?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Should I have Entity Manager in the Sequence diagram
 
Similar Threads
difference between sequence and collaboration diagrams
Cade component diagram and DAO
Sequence diagrams' details
Part II: Using DAOs in Class Diagram & Sequence Diagram
EntityManager on Sequence Diagram