wood burning stoves 2.0*
The moose likes Struts and the fly likes Difference between DAO,DTO,ACTION FORM, ENTITY CLASSES, SERVICES,FORM, MODEL CLASSES Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Difference between DAO,DTO,ACTION FORM, ENTITY CLASSES, SERVICES,FORM, MODEL CLASSES" Watch "Difference between DAO,DTO,ACTION FORM, ENTITY CLASSES, SERVICES,FORM, MODEL CLASSES" New topic
Author

Difference between DAO,DTO,ACTION FORM, ENTITY CLASSES, SERVICES,FORM, MODEL CLASSES

Vinod Vinu
Ranch Hand

Joined: Aug 30, 2009
Posts: 217
I often gets confused by these terms :-
DAO
FORM
SERVICES
ACTION FORM
ENTITY CLASSES
FORM
MODEL CLASSES

I know the input given by the User comes thru the action form to the struts action class.
but wat happens after that ?
we used to say that entity class are the replicas of tables, but how the DAO lies with the DB.
which one is interacting with the DB is it DAO or Entity class?

how each of these are interacting with eachother ?

thanks in advance.


Vinod Kumar Nair
"Any fool can write code that a computer can understan. Good programmers write code that humans can understand."
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You've mixed some generic terms with framework-specific ones, with one that doesn't even exist.

An ActionForm is a Struts 1-specific term and has no meaning outside of Struts 1. "Form" isn't really a term at all outside of HTML.

The rest can be looked up.
sarada bokka
Ranch Hand

Joined: Jan 13, 2010
Posts: 80
DAO is design pattern

For Entity,model

The below code is called javabean which comes as model in MVC(other things like action also comes under MVC).Model is where you write the bussiness logic.

supose if you are using hibernate and use the below User.java to relate with database table ,it is called as entity /persistance.



User.java



which one is interacting with the DB is it DAO or Entity class?


DAO uses entity .In the below DAO ,User is entity.


Vinod Vinu
Ranch Hand

Joined: Aug 30, 2009
Posts: 217
thank you all, but i want clarify once again that what sarada bokka has said

You mean to say that actually entity class is interacting with the db but with the help of DAO ?

and suppose if iam using all the frameworks , SRTUTS, SPRING and Hibernate

then what happens internally


STRUTS <-> spring <-> hibernate <-> DB

* STRUTS takes the input from user via Action form to its Action
* Inside action a 'Service'( service is a part of Spring) is called and DTO object is passed
* All the business logic written inside service gets called.
-> like which DAO( DAO is a part of Hibernate) to call, etc
* DAO then interacts with Entity class( Hibernate part) with the help of DTO
* Entity class interacts with DB
* SQL is performed
* goes back in the same order

DTO acts as a medium of passing the data from 1 layer to another layer
Is that Correct ?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Services are not "part" of Spring. Services are part of your business layer. Services might be configured and instantiated by Spring--but so might various other objects.

Entity classes don't interact with the DB: they're *filled* by something that interacts with the DB, but the actual DB interaction is done elsewhere.

Note that some of the "boundaries" between layers are often ill-defined, and that there is more than one way to do most of this stuff.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between DAO,DTO,ACTION FORM, ENTITY CLASSES, SERVICES,FORM, MODEL CLASSES