The 'correct' way would be to create an entity bean for each table that
is accessed from your database. If you use container managed persistence
you could do something like so:
public class News {
/** define all container managed fields (database fields) **/
public String title;
..
..
public Integer id;
/** Get methods **/
public String getTitle() { return title;}
..
..
public Integer getID() { return id;}
}
/** Use this one for compile time checking that EntityBean methods match
Remote interface**/
public interface NewsInterface {
/** Put all remote interface methods in here eg: **/
public String getTitle() throws RemoteException;
..
}
/** can leave this one blank (Remote Interface) **/
public interface NewsEnt extends NewsInterface, EJBObject {
}
/** Create and Finder methods **/
public interface NewsEntHome extends EJBHome {
...
}
public class NewsEntEJB extends News implements EntityBean,
NewsInterface {
/** put EJB methods in here. i.e. ejbCreate() etc **/
}
Hope this helps,
Damian.
>
> I'm looking into using orion to talk with a mySQL database that already
> exists (actually will exist). Is there a 'correct' way to map EJB's to
> existing tables (or any tools)? Or do I just create EJB's with the same
> name(s) and have persistent members that match the names of the existing
> table fields?
>
> Example table below:
>
> CREATE TABLE news
> (
> title TEXT NOT NULL,
> linktext TEXT,
> sm_date VARCHAR(12) NOT NULL,
> sm_time TIME NOT NULL,
> ctprovider VARCHAR(255),
> copyright VARCHAR(255),
> author VARCHAR(255),
> body TEXT NOT NULL,
> photo_count VARCHAR(12),
> doc_id VARCHAR(255),
> rev_id INT,
> abstract TEXT,
> filter VARCHAR(255) NOT NULL,
> id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
> )
>
> Thanks
>
> Jason Amy
> [EMAIL PROTECTED]