« Return to Thread: Displaying related data from JPA query in JSF table component

Re: Displaying related data from JPA query in JSF table component

by Rick Fincher :: Rate this Message:

Reply to Author | View in Thread

Since JPA uses pojos, can't you just create a new persistence entity
class that takes your two (or more) classes generated from your database
tables in the constructor and builds and populates the new class from
the sub-classes?

Rick

Nick Beare wrote:

> John,
>
> I have written a VW JSF /JPA App recently, having done Winston's 2 tutorials
> beginning with:-
> http://www.netbeans.org/kb/60/web/web-jpa.html
>
> My tables had related tables and I managed to use them without any problems.
>
> I don't know if you are using the VW JSF framework, if so you may find them
> useful.
>
> Regards
> Nick
>
> -----Original Message-----
> From: Futaleufu_John [mailto:jhalupka@...]
> Sent: 03 October 2008 14:34
> To: nbusers@...
> Subject: [nbusers] Displaying related data from JPA query in JSF table
> component
>
>
> I have an existing web app built using J2EE 1.4, JSF 1.1, MySQL and Tomcat
> 6.
> The DB has 40 tables with lots of links between tables. The DB will soon
> grow to 60+ tables with even more links.
>
> The current web app works fine - it's been up for almost a year - but
> managing inserts, updates and deletes is getting more and more complicated.
>
> I'd like to migrate from data providers to JPA. So far I like what I've seen
> of JPA but I'm still evaluating it.
>
> One problem is that the web app uses lots of table components that display
> information from related DB tables. That's easy to do with data providers.
> Not so easy to do with JPA, as far as I can tell.
>
> Simple example:
>
> I have a contact table whose fields are FKs to company (company name,
> website), address (address1, address2, city, state, zip code), and person
> (first name, last name, email) tables. I can execute a JPA query to get the
> contacts I want. I can bind the results to a table component. But I can't
> display any properties of the company, address or person objects. Winston
> suggested adding getters to the contact POJO, but that seems to be
> duplicating what's already there.
>
> Does anyone have another way to solve this problem?
>  

 « Return to Thread: Displaying related data from JPA query in JSF table component