[jboss-user] [JBoss Seam] - Re: Question on Stateless Session Bean
hasc
do-not-reply at jboss.com
Tue Mar 27 10:58:28 EDT 2007
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
More information about the jboss-user
mailing list