Friday, November 25, 2011

Spring security and JPA

Always remember to declare
"Spring OpenEntityManagerInViewFilter" before "springSecurityFilterChain" in web.xml.
Otherwise JPA calls to load entities would return entities successfully but without all properties (null values for entity fields).

Correct:

<filter-mapping>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
        ...
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

No comments:

Post a Comment