Solved

Open JPA query with One to Many Relation

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
database upgrade 8 70
Eclipse with gitlab 1 37
Component is listed with a Protocol more than once 3 27
mysql jsp example issue 32 32
Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

806 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