Solved

Open JPA query with One to Many Relation

Posted on 2009-04-02
2
2,144 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

726 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