jpa - What is Correct Way to implement a EJB to search using form parameters? -
i have bean works. implement method in order receive parameters jsf search form, perform search , return results.
so, questions are: - method signature wrap search parameters? - there way config hibernate/jpa behavior make single select returns registries fits search parameter instead of actual behavior (1 query excuted per row returned)?
import java.util.list; import javax.ejb.stateful; import javax.persistence.entitymanager; import javax.persistence.persistencecontext; import javax.persistence.persistencecontexttype; import javax.persistence.typedquery; import my.package.entity.address; @stateful public class addressejb { @persistencecontext(unitname = "rentacar-persistence-unit",type=persistencecontexttype.extended) private entitymanager entitymanager; public list<address> findall() { typedquery<address> query = entitymanager.createnamedquery( "address.findall", address.class); return query.getresultlist(); } /*this method want write*/ public list<address> findbyparameter() { typedquery<address> query = entitymanager.createnamedquery( "address.findall", address.class); return query.getresultlist(); } public address addnew(address address) { entitymanager.persist(address); return address; } public address update(address address) { entitymanager.merge(address); return address; } public void delete(address country) { entitymanager.remove(country); } }
Comments
Post a Comment