Re: OffTopic: Entity-Beans and relational structure
Hi Max, I don't know if it's much use, but an old tutorial I wrote on handling many-to-many relationships in Orion, using the exact same example you use, might be of use to you. You can find it here (it's also on Atlassian.com, but I don't have the link handy). http://users.sdsc.edu/~whedley/ejb/object_relational_mapping_in_orion.html http://users.sdsc.edu/~whedley/ejb/object_relational_mapping_in_orion.pdf A few things to note: * This is for EJB 1.1, EJB 2.0 defines a standard mechanism for handling this sort of problem. * This works on Orion 1.5.2 and OC4J 1.0.2.2.0, but I've received error reports on other versions of Orion. Someday, I'll get around to updating this document for EJB 2.0, but I'm swamped at the moment. Hope that helps, Warren Maximilian Eberl wrote: 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, but relational databases go far beyond that. I have a relational database for movies, actors, directors writers. ... -- Warren Hedley Alliance For Cell Signaling San Diego Supercomputer Center
Re: OffTopic: Entity-Beans and relational structure (out ofoffice 4/24-4/26)
I will be out of the office from the afternoon of Wednesday April 24th through the afternoon of Friday April 26th. If you have an emergency problem with the website, please contact Russell Dodds. thanks, Jen
SV: OffTopic: Entity-Beans and relational structure
Or you could use ContainerManagedRelationships (CMR) from the ejb2.0 specs. 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 Collection. 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? Cheers Jesper -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- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Maximilian Eberl 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, but 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 e.g.: 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) 1,1 2,1 1,2 3,3 .. and also tblMisEnScene, tblScreenplay meaning: Humphrey Bogart (actorid: 1) appeared in 'Casablanca' (filmid: 1) and 'The Maltese Falcon' (filmid: 2), Ingrid Bergman (actorid: 2) appeared 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 appear in multiple films. Relational basework, of course. If I want to extract those films in which Humphrey Bogart appeared I can do this easily in SQL (used by a Servlet) with: SELECT title FROM tblFilms WHERE id IN (SELECT filmid FROM tblRoles WHERE 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 do 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 problem because one film can have one or more writers (Casablanca had three) and (in 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 to help stupid persons) Maximilian Eberl http://www.derdickemax.de mailto:[EMAIL PROTECTED]
RE: OffTopic: Entity-Beans and relational structure
You don't need BMP to do this, CMP works just fine. Create separate entity beans for Movie, Actor, etc and establish many-to-many relationships between them. However, I will provide this warning: If you don't already know how to do this, that is, if you haven't already climbed the EJB learning curve, you will be a *lot* happier if you choose some other O/R mapping tool. Torque, Castor, Hibernate, JDO, or even just straight JDBC; with any of these solutions, your project will be up and running long before an entity bean solution, and it will perform a lot better too. Relationships in particular are hopelessly immature in Orion, and they're even painful in WebLogic. Jeff Schnitzer [EMAIL PROTECTED] -Original Message- From: Chris Nias [mailto:[EMAIL PROTECTED]] Sent: Wednesday, April 24, 2002 7:49 AM To: Orion-Interest Subject: 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- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Maximilian Eberl 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, but 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 e.g.: 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) 1,1 2,1 1,2 3,3 .. and also tblMisEnScene, tblScreenplay meaning: Humphrey Bogart (actorid: 1) appeared in 'Casablanca' (filmid: 1) and 'The Maltese Falcon' (filmid: 2), Ingrid Bergman (actorid: 2) appeared 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 appear in multiple films. Relational basework, of course. If I want to extract those films in which Humphrey Bogart appeared I can do this easily in SQL (used by a Servlet) with: SELECT title FROM tblFilms WHERE id IN (SELECT filmid FROM tblRoles WHERE 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 do 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 problem because one film can have one or more writers (Casablanca had three) and (in 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 to help stupid persons) Maximilian Eberl http://www.derdickemax.de mailto:[EMAIL PROTECTED]
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, but 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 e.g.: 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) 1,1 2,1 1,2 3,3 .. and also tblMisEnScene, tblScreenplay meaning: Humphrey Bogart (actorid: 1) appeared in 'Casablanca' (filmid: 1) and 'The Maltese Falcon' (filmid: 2), Ingrid Bergman (actorid: 2) appeared 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 appear in multiple films. Relational basework, of course. If I want to extract those films in which Humphrey Bogart appeared I can do this easily in SQL (used by a Servlet) with: SELECT title FROM tblFilms WHERE id IN (SELECT filmid FROM tblRoles WHERE 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 do 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 problem because one film can have one or more writers (Casablanca had three) and (in 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 to help stupid persons) Maximilian Eberl http://www.derdickemax.de mailto:[EMAIL PROTECTED]
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- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Maximilian Eberl 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, but 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 e.g.: 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) 1,1 2,1 1,2 3,3 .. and also tblMisEnScene, tblScreenplay meaning: Humphrey Bogart (actorid: 1) appeared in 'Casablanca' (filmid: 1) and 'The Maltese Falcon' (filmid: 2), Ingrid Bergman (actorid: 2) appeared 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 appear in multiple films. Relational basework, of course. If I want to extract those films in which Humphrey Bogart appeared I can do this easily in SQL (used by a Servlet) with: SELECT title FROM tblFilms WHERE id IN (SELECT filmid FROM tblRoles WHERE 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 do 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 problem because one film can have one or more writers (Casablanca had three) and (in 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 to help stupid persons) Maximilian Eberl http://www.derdickemax.de mailto:[EMAIL PROTECTED]