what good settlement query "layer" java jpa
in jpa entities good annotated plain aged java objects. nonetheless i have found good proceed correlate database.
in tide app, simple settlement always have method formed id primary pivotal i wholly have feeling adult entities properties pk.
and any entity i have stateless ejb
@stateless
public category myentapibean implements myentapi {
@persistencecontext(unitname = "xxx") @inject entitymanager entitymanager;
with query methods mutation
/**
* @return list myents have property
* @param someprop property
*/
public list<myent> getallmyentsfromprop(final twine someprop) {
try {
final query query = entitymanager.createquery("select me myent me where me.someprop = :someprop");
query.setparameter("someprop", someprop);
relapse query.getresultlist();
} catch(final noresultexception nre) {
log.warn("no myents found");
}
relapse new arraylist<myent>();
}
so:
i unequivocally loathing carrying methods an ejb since seem go entities themselves, ejb internal interfaces stimulate crap out me.
i loathing duplication i have any slight "try, createquery, getresultlist,catch, log, return" (mostly effect closures "with statement" somesuch java).
does anyone have idea improved proceed correlate entities database addresses both issues?
i am now pondering doing bottom methods generics tact general query methods devaluate duplication (issue 2) (i put antecedent adult hearing later).
thanks,
anders
Comments
Post a Comment