java - Simplify DAO Layer with Resteasy / Hibernate / Spring -
i'm looking cleaner code dao layer :
i have generic dao interface :
public interface genericdao<t> { t save(t entity); t merge(t entity); void delete(t entity); t findfromid(int id); list<t> findall(); }
an abstract implementation :
public abstract class abstractgenericdaoimpl<t> implements genericdao<t> { [...] }
for each database entity, have 2 files :
an interface :
public interface userdao extends genericdao<userpe> { }
a concrete class :
@repository public class userdaoimpl extends abstractgenericdaoimpl<userpe> implements userdao { [ no code entities ] }
i'm using spring injection :
@autowired private userdao userdao;
i'd use generic dao common entities, :
@autowired private genericdao<myentity> myentitydao;
but spring doesn't want inject (nosuchbeandefinitionexception) , don't know how configure hibernate queries (which needs entity classes).
i'm using : spring 3.1.0 hibernate 3.6.3 resteasy 2.3.7
do have idea ?
thks reading.
if use spring 4, able use
@autowired private genericdao<myentity> myentitydao;
if there implementation of genericdao without doing else.
such capability missing in spring 3. check out this blog post more details.
however, if introduce spring 4 project might break integration resteasy. that's you'll need check.
Comments
Post a Comment