java - Hibernate and Spring - Dao ,Services -


i've been reading tutorials , see of mvc implementations

are based on:

1) dao interface example "iuserdao"

2) dao impl of interface - "mysimpleuserdaoimpl"

3) service interface persistance : "iuserservice"

4) , impl - "userserviceimpl"

is best practice? mean reason ask question because seem redundant have 30 services getxbyid(), deletex(x), createx(x) methods doing more or less same.

please take account i'm using spring 3 , hibernate 4, , decided ask question before start slamming keyboard code

thanks.

if starting development, spring jpa. service should one-to-many repositories (dao). not create of boilerplate code hand anymore. spring jpa eliminates basic crud , search functions pagination.

here video walks through of configuration spring, jpa, hibernate, , finishes spring data jpa showing of boilerplate code eliminated.

to use spring data jpa, repository interface ends being:

package com.mysampleapp.repository; import org.springframework.data.jpa.repository.jparepository; import org.springframework.stereotype.repository; import com.wcfgroup.model.employee;  @repository("employeerepository") public interface employeerepository extends jparepository<employee, long> {     employee findbyssn(string ssn); } 

and xml configuration use spring data jpa:

<jpa:repositories base-package="com.mysampleapp.repository"/> 

all of boilerplate code handled you. no longer need create basic repository class find methods , basic crud functions. jparepository interface offers lot of nice features , don't have implementation.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -