Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Should I have Entity Manager in the Sequence diagram

 
Luay Abdulraheem
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pratik Bhavsar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 133
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Krzysztof Koziol
Ranch Hand
Posts: 133
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic