[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-1814) DataModel wrapped data is set to null by ManagedEntityIdentityInterceptor

Alex Savitsky (JIRA) jira-events at lists.jboss.org
Wed Jun 4 14:38:20 EDT 2008


    [ http://jira.jboss.com/jira/browse/JBSEAM-1814?page=comments#action_12415628 ] 
            
Alex Savitsky commented on JBSEAM-1814:
---------------------------------------

I believe one quick way to improve this interceptor would be to enhance checks in the toRef() method. Right now, it basically believes anything that is a List, Map, or Set, to be a collection of entities.

First, quite obvious, change might be to change this to only check if the passed value is a Collection (unless there were good reasons to specifically check for java.util collection types only).

Second improvement should be to check whether it's empty (empty collections are guarante3ed not to hold any entities :)

And third improvement would be to check the first element in the collection, if it's not empty. If this element is an entity, then it's a collection of entities.

Something like that, maybe:

	@SuppressWarnings ("unchecked")
	private boolean isRef(Object value) {
		if (value instanceof Collection) {
			Collection c = (Collection) value;
			if (!c.isEmpty()) {
				Object o = c.iterator().next();
				return Seam.getEntityClass(o.getClass()) != null;
			}
			return false;
		}
		return Seam.getEntityClass(value.getClass()) != null;
	}

I'd like to find out from developers, though, whether the check for a Collection is adequate - if not, then I'll have to check separately for each of List, Map, and Set.

> DataModel wrapped data is set to null by ManagedEntityIdentityInterceptor
> -------------------------------------------------------------------------
>
>                 Key: JBSEAM-1814
>                 URL: http://jira.jboss.com/jira/browse/JBSEAM-1814
>             Project: Seam
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.0.BETA1
>         Environment: seam cvs (20070816.1709)
>            Reporter: Matt Drees
>         Assigned To: Norman Richards
>            Priority: Minor
>             Fix For: The future
>
>
> The following test fails:
> @Name("dataModelComponent")
> @Scope(ScopeType.CONVERSATION)
> public class DataModelComponent extends EntityQuery {
>    @Override
>    public String getEjbql() {
>       return "from java.lang.Object o";
>    }
> }
> public class DataModelComponentTest extends SeamTest {
> 	
>    @Test
>    public void test() throws Exception {
>       new FacesRequest() {
>          @Override
>          protected void renderResponse() throws Exception {
>             DataModel model = (DataModel) getValue("#{dataModelComponent.dataModel}");
>             assert model.getWrappedData() != null;
>          }
>       }.run();
>    }
> }
> Because the component is conversation-scoped, a ManagedEntityIdentityInterceptor is attached, which nulls the wrapped List after getDataModel() is called.
> In the referenced forum, Gavin indicated he hadn't decided whether this should be expected behavior or not, and asked for a jira issue.  
> If it is expected behavior (I hope not), I think either EntityQuery should not have a getDataModel() attribute, or it should be documented and/or programmatically enforced that EntityQuerys should not be conversation-scoped.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list