I’m trying to show data from multiple tables on a jsf page.
The page is bound with the backing bean.
Now, there are many ways to do it.
Method 1: I can get the entire table_row on the entity object generated by hibernate using the entity objects.
Method 2: I can create POJO’s (Value beans) which hold the data and write queries myself in HQL.
NOTE : The data is coming from multiple tables.
Some people suggested the first method and some suggested the second.
Now the question is
When i need specific columns of specific tables, why do i retrieve a whole row from the db but on the other hand a thought comes that what are the entities for, then ?
I hope i explained my problem well.
Please guide.
Personally, I would go with the second method.Just have the backing beans call a DAO method to populate a POJO instance created in the bean. If a lot of the data is not needed. This way you can query only the data you needed, but if you ever thought in the future some of the other data will be used you would already have the backend coded to retrieve it in the entity class where with the pojo you would have to change the DAO, POJO, and JSF.