[jboss-user] [JBoss Seam] - Recommended way of using Select boxes - The Seam Way
scott.stark@jboss.org
2007-07-16
I am attempting to load a SelectOneMenu with a list of entities. I then want to use the selection in a query to get another entity. Seems like a simple use case so far.
Should I be using the entity from SelectOneMany or just its id field to filter the query?
I am getting a bunch of weird TransientObjectExceptions when my page loads/reloads.
Here is an example of what I am doing
I have a SelectOneMenu with a list of LandmarkType entities (filled from entity-query "allLandmarkTypes") that have a one to many relationship with Landmark entity. I wish to fill a list of Landmarks based on my LandmarkType selection
| @Stateful | @Name("addressLocator") | public class AddressLocatorAction implements AddressLocator { | | @In(required=false) | private LandmarkType landmarkType; | | @Out(required=false) | List<Landmark> landmarkList; | | @Factory("landmarkList") | public void fillLandmarkList() { | | landmarkList = entityManager.createQuery("SELECT l from Landmark l WHERE l.landmarkType = :landmarkType" + | " OR :landmarkType IS NULL ORDER BY l.landmarkName").setParameter("landmarkType",landmarkType).getResultList(); | | } | .... |
So my question is, should I be dealing with the LandmarkType entity directly or should I just use its Id to filter the Landmark List. I am concerned about the state of the LandmarkType entity. What is the recommended way of dealing with this seemingly simple use case?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4064755#4064755
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4064755 _______________________________________________ jboss-user mailing list jboss-user@(protected) https://lists.jboss.org/mailman/listinfo/jboss-user