Use JPA with Hibernate in Netbeans(Tomcat)
-
prerequisite
Tomcat 6.0.14
Netbeans 6 rc1
Hibernate core 3.2.5GA
Hibernate EntityManager 3.3.1GA -
Add a new JPA library implement
The default used TopLink. Change to Hibernate.
-
Adjust in JSF design
The default data provider ObjectArrayDataProvider works not well with JSF design UI.
My target is when let a jsf table “Bind to Data”, the all fields of a Hibernate JOPO can be chosen as the above dialog. These displayed fields come from provider’s getFieldKeys method which is part of interface DataProvider signature. So the simplest way is to extends ObjectArrayDataProvider and overide that method. Or just use setObjectType(Student.class). Be sure to compile that class manually so the JSF Design can take this change into account.
Why not use :
private ObjectArrayDataProvider objectArrayDataProvider1 = new ObjectArrayDataProvider(someType);It does not work. Even I put them in _init() method of backend bean, as the CachedRowSet provider does.
- Done.