I am developing a project using Hibernate and JSF. My question is:
Can I directly manipulate Hibernate POJO’s from my backing bean? I.e. in my form can I refer #{mybackingBean.myPOJO.propertyName}?
From myBackingBean, can I call methods like findAll(), save(), findById(id)?
Is this good design or if any complications exist please advice me.
Yes, you can do so.
Yes, you can do so. I however expect to see those methods in a service/DAO class, not in a POJO.
Depends on the functional/business requirements. If you need to design your JSF views based on the data model, then you can often just use the POJOs as-is. If you however need to design your JSF views based on a business model which does not necessarily fit 1-to-1 with the data model, or when you want to abstract the data layer completely away (i.e. Hibernate is merely a “implementation detail” and supposed to be exchangeable with Plain JDBC or the modern JPA), then you often need to introduce an extra abstract layer with DTOs which are mapped from/to POJOs and then use only those DTOs in JSF side. In any way, you should not explode the POJO/DTO in a JSF backing bean, but just make the whole entity a property of it and use it as
#{bean.entity.property}.