-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Looking for guidance on using Hibernate in a web service
PostPosted: Wed Oct 08, 2014 6:01 pm 
Newbie

Joined: Wed Oct 08, 2014 12:05 pm
Posts: 2
I typically use mybatis and stored procedure as my application/database bridge but I'm evaluating hibernate for a new project. There are some aspects of Hibernate that seem neat, but I'm not convinced it's going to solve more problems for me than it creates. So, please help me understand if I should pursue Hibernate for my application.

The hibernate documentation suggests that the Session object should be re-used for multiple database transactions that span a single 'unit of work'. However, my application will exist behind a stateless REST api and so, the Session can not persist between requests. It seems then the Session-Per-Request pattern must be used. Does this pattern work? Do you pay too much overhead for creating a Session for each CRUD operation that you use for one operation and then close? A typical workflow might be:
1) User issues a GET request for an object by ID.
2) Create a Session and load the object.
3) Close session, serialize the object to JSON and deliver in response.
4) User POSTs modifications to object with new JSON payload.
5) Deserialize JSON into an entity instance.
6) Create a new Session.
7) Start a transaction.
8) Persist the object.
7) Commit transaction and close the Session.

Is this the right way to leverage Hibernate?

Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.