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:




  1. i unequivocally loathing carrying methods an ejb since seem go entities themselves, ejb internal interfaces stimulate crap out me.


  2. 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

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?