No, landmarkType does not have a value when fillLandmarkList() is called on
initial page load. Since fillLandmarkList is an @Factory method, it is called
as soon as the page loads, no landmarkType has been selected from the Select
box yet.
I fixed the error message but still don't really understand the "why" yet.
Here is my new code
@Factory("landmarkList")
| public void fillLandmarkList() {
| if (landmarkType.getLandmarkTypeId() != null) {
| if (!(entityManager.contains(landmarkType))) {
| landmarkType =
entityManager.getReference(LandmarkType.class,
landmarkType.getLandmarkTypeId());
| }
| landmarkList = (List) landmarkType.getLandmarkCollection();
| } else {
| landmarkList = entityManager.createQuery("SELECT l from
Landmark l ORDER BY l.landmarkName").getResultList();
| }
| }
It seems that landmarkType is instantiated by Seam when the page loads because
of the reference to #{landmarkType} in the SelectOneMenu. It is instantiated
to a new landmarkType with null values in its elements. I think that is why I
was getting a Transient object exception, because Hibernate thought it was a
newly created entity that has not been persisted yet.
I am on track here?
I just don't understand why Seam is creating the landmarkTypecomponent in the
first place. It does not specify a create=true in the declaration.
@In(required=false)
| private LandmarkType landmarkType;
|
Am I approaching this properly?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4065017#4065017
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4065017
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user