Understanding ask, Whats the correct way using .save() and .commit() in Hibernate from the programming layers model Perspective

StackOverflow https://stackoverflow.com/questions/19935559

Lets say, i got 2 Java Projects,

one Project manages the connect to the Database, the other one is the Data-Access-Object-Project.

In my Database Project i got the POJO´s (with Annotations) and i initialize my Session Factory, Session and Transaction objects.

In my DAO-Project i got my CRUD-Object (Create, Read, Update, Delete)

Am i right (layers model Perspective), when i say, that my DAO-Project delegates the SESSION.save() and the TRANSACTION.commit() to the Database Project, or do i use the Session Factory/ Session/transaction, which i instantiated in the Database Project in the DAO-Project?

有帮助吗?

解决方案

I did not get your question fully. But my understanding is you have two projects(modules). One module deals with hibernate/database stuffs and another model deals only CRUD operations...

First of all Transaction is not the responsibility of data access layer (I fell both the modules deals with database so i assume both are data access layers). Its good that you have intention to abstract away the CRUD operations from infrastructural stuffs.But i'm not sure of implementation possibilities but it may be achieved with patterns like proxy.From layered model Perspective it is good to separate CURD operation from database project.

Cheers!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top