after a while i got this working.

@Stateless
  | @Name("building")
  | public class BuildingListAction implements BuildingList,Serializable{
  |     
  |     private static final long serialVersionUID = 1L;
  |     
  |     private List<BuildingType> objects;
  |     Map<String,BuildingType> buildingsMap;
  |     
  |     @PersistenceContext 
  |     EntityManager em;
  |     
  |     public Map<String,BuildingType> getBuildings()
  |     {
  |             objects = em.createQuery("select b from BuildingType b")
  |         .setHint("org.hibernate.cacheable", true)
  |         .getResultList();
  | 
  |       Map<String,BuildingType> results = new TreeMap<String,BuildingType>();
  |       
  |       for (BuildingType buildingtype: objects)
  |       {
  |             results.put(buildingtype.getName(),buildingtype);
  |       }
  |       
  |       buildingsMap = results;
  |             
  |             return buildingsMap;
  |     }
  | 
  |     public Converter getConverter()
  |     {
  |         return new BuildingTypeConverter(objects);
  |     }
  | }


im not familiar with ejb but this obviously leads to a query every time the 
method getBuildings() is called. My goal is to load the objects only once and 
then return a list every time the methos is called. Can somone help me with 
that or point me to an example or tutorial which describes that?

regards,
hasc


View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4032071#4032071

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4032071
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to