Solved

Open JPA query with One to Many Relation

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now