How to set a Http Session parameter in a JPA named query -


I want to set a parameter in a named query (JPA 2.0), so my datatable will present the relevant dataset. The parameter is obtained remotely and the abstrate is injected into the famed class.

I have tried to get it through the code given above, but it is not working. Can anyone help me?

Sarfachet (Main Code):

  Private string prefix; Public listing & lt; T & gt; FindByPrefDep () {prefDep = FacesContext.getCurrentInstance (). GetExternalContext (). GetSessionMap () Get ("xPrefDep"); Javax.preistence.criteria.CriteriaQuery cq = getEntityManager () GetCriteriaBuilder (). CreateQuery (); Cq.select (cq.from (entityClass)); Return getEntityManager (). CreateQuery (cq) .setParameter ("prefDep", prefDep) .getResultList (); }  

Entity Class (Main Code):

  @NamedQuery (name = "capacitacao.findByPrefDep", query = "Choose from Capsitec C, C WHERE C .prefDep =: prefDep "),  

Synchronous:

  public archive & lt; T & gt; GetItems () {If (item == empty) {items = this.ejbFacade.findByPrefDep (); } Return the baggage; }  

No exception has started, but the dataset has been searched, all matches the named query.

Thanks in advance.

Your code does not use any of your named queries exactly the name of a named query, and your The code does not use anywhere with that name

getEntityManager (). Vs. Normandie ("Capacitacaoafindbieprideep", Capacitocao class.) Sitemapator ("prefep deep", prefep deep) .GueterSlatlist ();

You could get yourself from reading just by yourself.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -