Solved

Open JPA query with One to Many Relation

Posted on 2009-04-02
2
2,142 Views
Last Modified: 2013-12-07
How to fetch data from a child table by querying on parent table in openjpa which is One-to-Many Relationship.
0
Comment
Question by:vkchaitu82
2 Comments
 
LVL 3

Accepted Solution

by:
kingsob earned 500 total points
ID: 24110032
here is a query what will select all children for a parent

select p from Parent p join fetch p.children where p.id = :id

you could then display a list of the children in jsf with something like this (assuming the child table had a column called name)

<h:dataTable "#{bean.parent.children}" var="child">
    <h:column>
        <h:outputText value="#{child.name}"/>
    </h:column>
</h:dataTable>

you would also need a getter in your bean for the public Parent getParent();


if you were to post your two entity's for the parent and child, i could be more specific to your needs


Derek
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question