persistence@glassfish.java.net

RE: question on entity relationships

From: James Sutherland <jamesssss_at_yahoo.com>
Date: Mon, 3 Dec 2007 07:08:22 -0800 (PST)

Do you have any LamManufacturerent that have Lampent? This query will filter
out the none case, i.e. you will only get back LamManufacturerents that have
1 or more Lampent.

You could use an outerjoin if you do not wish to filter the none case.

i.e.
SELECT l.pnumb, l.catergory, l.lwoltage, lm.manuname FROM LamManufacturerent
lm left outer join lm.lampent l


Eve Pokua wrote:
>
>
> Hello James/Everyone, I have finally tried your suggestion but I'm
> having problems retrieving data. Below are my to related entities with
> their relationships: @Entity_at_Table(name="LAMPS") @Named Queries({
> @Named Query(name ="getAlldetails", query=" SELECT l.pnumb, l.catergory,
> l.lwoltage, lm.manuname FROM LamManufacturerent lm, in(lm.lampent) l")}
> public class Lampent implements Serializable{ .........................
> @ManyToOne private LamManufacturerent
> lamManufacturerent;................... } @Entity_at_Table(name="LAMPMANU")
> public class LamManufacturerent implements
> Serializable{............................ @OneToMany(mappedBy =
> "lamManufacturerent") private List<Lampent> lampent; .............
> } Here is the JPQL: @Named Query(name ="getAlldetails", query=" SELECT
> l.pnumb, l.catergory, l.lwoltage, lm.manuname FROM LamManufacturerent lm,
> in(lm.lampent) l") Did I get it wrong because it is not working and not
> retrieving any data. It however works, if I do some thing like this:
> "Select l FROM Lampent l" It brings all data plus all the data from the
> related entity LamManufacturerent. But i only want manuname from
> LamManufacturerent. Im probably making just a little mistake. Please,
> help. Thankseve ________________________________> From:
> gorgeous65_at_msn.com> To: persistence_at_glassfish.dev.java.net> Date: Wed, 14
> Nov 2007 15:07:03 +0000> Subject: RE: question on entity relationships> >
> Thanks James> > I will try it and let you know.> > eve> >> Date: Wed, 14
> Nov 2007 06:20:25 -0800>> From: jamesssss_at_yahoo.com>> To:
> persistence_at_glassfish.dev.java.net>> Subject: Re: question on entity
> relationships>>>>>> The JPQL would be,>>>> "Select i.id, i.name,
> i.description, i.colour, i.size, o.oid, o.date,>> o.quantity from Order o,
> in(o.items) i">>>> You could also just select the Order and fetch join the
> items, if you wanted>> the objects back. Or just select the Orders can
> access the items from them>> in Java.>>>> "Select o from Order o join
> fetch o.items">>>> "Select o from Order o">>>>>> Eve Pokua wrote:>>>>>>>>>
> Hello everyone,>>>>>> I would like to know how to retrieve certain data
> from the DB with respect>>> to entity relationship. Consider the following
> SQL statement.>>>>>> "Select i.id, i.name, i.description, i.colour,
> i.size, o.oid, o.date,>>> o.quantity from Item i, Order o">>>>>> Or a very
> complex SQL statement using JOIN in tables.>>>>>> The Order entity is a 1
> to many relation to Item - an order can have many>>> items. But when
> retrieving the details from order, I want to see certain>>> data from the
> Order table as stated above, but not all the data from>>> Order. How do I
> achieve this in EJB3 query?>>>>>> Thanks>>>>>> eve>>>>>>>>> ----->> --->>
> http://wiki.eclipse.org/User:James.sutherland.oracle.com James
> Sutherland>> http://www.oracle.com/technology/products/ias/toplink/ Oracle
> TopLink ,>> http://www.eclipse.org/eclipselink/>> EclipseLink ,
> https://glassfish.dev.java.net/javaee5/persistence/ TopLink>> Essentials>>
> Wiki: http://en.wikibooks.org/wiki/Java_Persistence Java Persistence ,>>
> http://wiki.eclipse.org/EclipseLink EclipseLink>> Forums:
> http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,>>
> http://www.nabble.com/EclipseLink-f26430.html EclipseLink ,>>
> http://www.nabble.com/java.net---glassfish-persistence-f13455.html
> Glassfish>> Persistence>> -->> View this message in context:
> http://www.nabble.com/question-on-entity-relationships-tf4804935.html#a13747259>>
> Sent from the java.net - glassfish persistence mailing list archive at
> Nabble.com.> > ________________________________> Get free emoticon packs
> and customisation from Windows Live. Pimp My
> Live!<http://www.pimpmylive.co.uk>
> _________________________________________________________________
> Get free emoticon packs and customisation from Windows Live.
> http://www.pimpmylive.co.uk
>


-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.oracle.com/technology/products/ias/toplink/ Oracle TopLink , 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  https://glassfish.dev.java.net/javaee5/persistence/ TopLink
Essentials 
Wiki:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence , 
http://wiki.eclipse.org/EclipseLink EclipseLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink , 
http://www.nabble.com/java.net---glassfish-persistence-f13455.html Glassfish
Persistence 
-- 
View this message in context: http://www.nabble.com/RE%3A-question-on-entity-relationships-tf4930046.html#a14131601
Sent from the java.net - glassfish persistence mailing list archive at Nabble.com.