Sequence Diagram for interaction between hibernate and database

1.2k Views Asked by At

I need to create a general sequence diagram for the the interaction of hibernate and a any database.

It needs to be very generic and application to all transaction between hibernate and database

What are the main methods involved in opening, fetching data and closing of a hibernate session with the database

1

There are 1 best solutions below

1
On BEST ANSWER

A sequence diagram shows relationships between some object instances, which ones do you have mind? At one level it's just a database and a hibernate application. In which case you've just done it: Open, Fetch (or other query), Close.

Now presumably you want more detail than this, but I think we need to know why you're drawing this diagram. Who is going to read this, what are they interested in? Consider this this simple tutorial, they show a code snippet:

SessionFactory sessionFactory = new
Configuration().configure().buildSessionFactory();
Session session = sessionFactory.openSession();
Transaction transaction = session.beginTransaction();
BallPlayer aPlayer = (BallPlayer) session.get(BallPlayer.class, 1L);
transaction.commit();
session.close();

So now we have several interesting objects, SessionFactory, Session and so on. For a programmer about to work with Hibernate this might be interesting. For a DBA maybe less so? You can quite easily draw a sequence diagram of the above snippet, and it has some truth in it. I can't understand the value such a diagram, but that's another story.