My project is built on Spring + JPA + Hibernate.
In my web.xml I have
Code:
<filter>
<filter-name>OpenEntityManagerInViewFilter</filter-name>
<filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>OpenEntityManagerInViewFilter</filter-name>
<servlet-name>spring</servlet-name>
</filter-mapping>
JPA Entity:
Code:
@Entity
public class Cat
{
...
@ManyToOne(fetch = FetchType.LAZY, optional = false)
private Person master;
...
}
Controller:
Code:
@Controller
public class CatController {
@PersistenceContext
protected EntityManager entityManager;
@RequestMapping("/cat")
public ModelAndView cat() {
ModelAndView mav = new ModelAndView("cat");
Cat cat = entityManager.find(Cat.class, 1);
mav.addObject(cat);
return mav;
}
}
JSP:
Code:
${cat.master}
In Tomcat JSP shows master field properly, in Glassfish it displays null.
Why ?