Hi All,
In our Spring/Hibernate based project, we are in the design stage. In this, i ran into a question of where should the biz logic be written. Should it be in Session Facade (which is implemented as stateless (local) session bean, in our case) or in the Business facade (which is also a service layer?).
Per my understanding, Session Facade will provide one point interface to the client. Session Facade will call the Business Facade. For example, we've various POJOs (e.g Application) and for each of the POJOs or related POJOs, we'll have the service layer API (e.g ApplicationManager). If the ApplicationManager has a method called saveApplication, this method will carry out biz rules a, b, c before saving the application POJO using the corresponding DAO interface. SessionFacade will call appropriate service layer API.
Is that the recommended approach???
Also, in our case, for certain CRUD operations, we are planning to use Hibernate and for others, especially queries, we are planning to use just Spring's JdbcTemplate and even stored procedures, if required for performance reasons.
My question is, within the same transaction can mix and match the use of Spring based JdbcTemplate for querying, HibernateTemplate for saving and stored procedure for some other logic (only if required). In this case, will spring manage the DB transaction/connection for all of them. What happens if we persist (save) more than one objects within the same transaction and one of them fails. In this case, will spring rollback all of them?
Is it logical to mix and match Spring based JDBC operations vs Hibernate within the same transaction?
Could someone please share your thoughts on this?
Thanks for any input in advance!
In our Spring/Hibernate based project, we are in the design stage. In this, i ran into a question of where should the biz logic be written. Should it be in Session Facade (which is implemented as stateless (local) session bean, in our case) or in the Business facade (which is also a service layer?).
Per my understanding, Session Facade will provide one point interface to the client. Session Facade will call the Business Facade. For example, we've various POJOs (e.g Application) and for each of the POJOs or related POJOs, we'll have the service layer API (e.g ApplicationManager). If the ApplicationManager has a method called saveApplication, this method will carry out biz rules a, b, c before saving the application POJO using the corresponding DAO interface. SessionFacade will call appropriate service layer API.
Is that the recommended approach???
Also, in our case, for certain CRUD operations, we are planning to use Hibernate and for others, especially queries, we are planning to use just Spring's JdbcTemplate and even stored procedures, if required for performance reasons.
My question is, within the same transaction can mix and match the use of Spring based JdbcTemplate for querying, HibernateTemplate for saving and stored procedure for some other logic (only if required). In this case, will spring manage the DB transaction/connection for all of them. What happens if we persist (save) more than one objects within the same transaction and one of them fails. In this case, will spring rollback all of them?
Is it logical to mix and match Spring based JDBC operations vs Hibernate within the same transaction?
Could someone please share your thoughts on this?
Thanks for any input in advance!
Comment