Or you could use ContainerManagedRelationships (CMR) from the ejb2.0
With this you define the relationships between the beans in the
ejb-jar.xml, and declare the abstract getters and setters yo use Set or

Be warned that you have to use the 1.5.4 Orion and some of the
relational integrities is not fully implemented/bugfree. It all works
fine but you have to handle the move (remove and add) yourself (or leave
it be and wait for 1.5.5 :)

Have anyone tried it with oracle?


-----Oprindelig meddelelse-----
Fra: Chris Nias [mailto:[EMAIL PROTECTED]]
Sendt: 24. april 2002 16:49
Til: Orion-Interest
Emne: RE: OffTopic: Entity-Beans and relational structure

If you get the Java 2 Enterprise Edition Developers Guide (I have v
1.2.1 pdf) from www.java.sun.com 
Then it is on page 135 - Mapping Table Relationships to Entity beans
It goes on to describe when you should use entity beans, and when to use
helper classes (hint: that is what you need!)
It also gives a good example with source code.
Be warned though; you will have to use BMP!

-----Original Message-----
[mailto:[EMAIL PROTECTED]] On Behalf Of Maximilian
Sent: 24 April 2002 13:13
To: Orion-Interest
Subject: OffTopic: Entity-Beans and relational structure

Excuse me for asking off topic (and stupid), I am just learning to use
Entity Beans on Orion.

In most tutorials entity beans only represent ONE ROW from ONE TABLE,
relational databases go far beyond that.

I have a relational database for movies, actors, directors & writers.

So I have a table tblMovies
INT id, VARCHAR title, INT year, VARCHAR description
1, 'Casablanca',1942,'the classical movie'
2, 'The Maltese Falcon',1946,'begin of the dark series'
3, 'The Seawulf',1947,'after the novel from Jack London'

I have a tblActors (INT id, VARCHAR name)
1,'Humphrey Bogart'
2,'Ingrid Bergman'
3,'Edward G. Robinson'

and in the same manner tblDirectors, tblWriters

And I have tables for the relations, e.g.

tblRoles (INT filmid, INT actorid)
and also tblMisEnScene, tblScreenplay

meaning: Humphrey Bogart (actorid: 1) appeared in 'Casablanca' (filmid:
and 'The Maltese Falcon' (filmid: 2), Ingrid Bergman (actorid: 2)
in 'Casablanca' (filmid: 1), Edward G. Robinson (actorid: 3) appeared in
'The Seawulf' (filmid: 3) . So this relational structure allows that one
film can have multiple actors, writers, directors and one actor can
in multiple films. Relational basework, of course.

If I want to extract those films in which Humphrey Bogart appeared I can
this easily in SQL (used by a Servlet) with:

SELECT title FROM tblFilms WHERE id IN (SELECT filmid FROM tblRoles
actorid=(SELECT id FROM tblActors WHERE name='Humphrey Bogart'))

(or as in my case with JOINS from MySQL)

When I do want to write an EJB-Application using this database, how do I
this ? How do I represent the relational data ?

Do I have to keep Entity Beans for EVERY row of ANY table ? Do I have to
create temporary tables with all information merged ? This creates a
because one film can have one or more writers (Casablanca had three) and
most cases) more than one actor.

This way  ?

public class MovieBean implements javax.ejb.EntityBean
    String Title;
    String[] Actors;
    public String getTitle() throws RemoteException;
    public String[] getActors() throws RemoteException;
        return Actors[];

using Arrays filled from the database with all actors, directors,
writers ?

Please give me a hint ! (Well, I know I am stupid. But it is a good work
help stupid persons)

Maximilian Eberl

Reply via email to