This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between DAO and hibernateDAO file?

 
M sallu
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have one employee table but I see two files, one is employeeDAO.java and other is employeeHibernateDAO.java. And the employeHibernateDAO is defined like this
public class employeeHibernateDao extends AbstractHibernateDao<employee> implements employeeDao {

under package

+com.company.emp.dao
+employeeDAO.java
+com.company.emp.hibernate.dao
+employeeHibernateDAO.java
......
+mappingfiles
+employee.hbm.xml //And only one mapping file(obviously) to connect to that table.

My question: What is the difference between DAO and HibernateDAO file?
also ..........AbstractHibernateDao<employee>..... now what is this employee class again... is it the DTO?
What does DTO do?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like employeeDao is an interface--so the difference is that one is an interface and one is an implementation. It's not a DTO, it's a DAO, like the name implies: http://www.coderanch.com/t/99834/OO-Patterns-UML-Refactoring/what-difference-between-DTO-DAO
 
M sallu
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes employeeDAO is interface and employeeHibernateDAO implements employeeDAO
and employee is a class where all the elements are defined :: String employeename; calendar StartTime; etc, etc...and their getters and setters.

Now how are transactions taking place? How is the employee.hbm.xml mapping file used, etc?

Lets say I need to retrieve the value employeename from table

Do I have new constructor employeeDAO employeedao = new employeeDAO;

or

eployeeHibernateDAO empHibdao = new employeeHibernateDAO;

I am not sure whether to call the interface or implementation...I am confused.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instantiating interfaces isn't possible. A DAO instance should be declared as the interface, and an implementation should be instantiated (here, the Hibernate one).

I'm not sure what you're asking when you talk about the Hibernate mapping file and transactions; the mapping file is used during Hibernate initialization, transactions are handled by you, or by Spring, or by the container, or...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic