This week's book giveaway is in the Spring forum.
We're giving away four copies of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 and have Marten Deinum & Iuliana Cosmina on-line!
See this thread for details.
Win a copy of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

EJB-QL Question

 
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If we had a "Boss" EJB with a single CMR field named "employee", and an Employee EJB using a "Pay" class as its pay CMP field, are both of these allowable:

SELECT b.employee FROM Boss b
SELECT b.employee.pay FROM Boss b

--Dale--
[ May 15, 2004: Message edited by: Dale Seng ]
 
Dale Seng
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a second question, if you please...

Say we have a one to many relationship: House 1 ---- * Room (a house is made of of several rooms, one room may belong to only one house), and House has a collection-valued relation field whose value is 'room'.

Our database looks like this:



Can we do this:

SELECT OBJECT(h)
FROM House h, IN(h.room) r
WHERE r = 'Kitchen'

--Dale--
[ May 15, 2004: Message edited by: Dale Seng ]
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi-

I guess when you say a 1--* relationship, it's more better represented when the entities are different tables - House table and Room table (you know, normalization and stuff)
and, technically, when you say a collection-valued relation field - 'room', it's a getter method getRoom() (or more comfortably getRooms() when your cmr-field is 'rooms') which will return a Collection of local component interfaces of the Room entity bean (a different table), so that you can iterate thru them. your database might actually have to be modified as

in this case your EJB-QL would look something like -

hope this helps
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic