Automate generation of Session Bean
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   gaurav_bansal
Posted On:   Wednesday, October 17, 2007 03:16 AM

Hi... I am trying to make an application (in NetBeans IDE) which can be plugged with different databases having similar information but different schema. Say in one database the "employee email" is in the same table as the "employee id and name" and in another "employee id and name" are in same table and "employee email" in another. Now my application wants the "employee email" and uses a function call "getEmployeeEmail". Using EJBs, the entity bean gets generated automatically according to the database schema but the Session bean has to be manually coded to implement the function call "getEmployeeEmail" where I have to write the query as per the schema/entity bean.    More>>

Hi...
I am trying to make an application (in NetBeans IDE) which can be plugged with different databases having similar information but different schema.
Say in one database the "employee email" is in the same table as the "employee id and name" and in another "employee id and name" are in same table and "employee email" in another.

Now my application wants the "employee email" and uses a function call "getEmployeeEmail". Using EJBs, the entity bean gets generated automatically according to the database schema but the Session bean has to be manually coded to implement the function call "getEmployeeEmail" where I have to write the query as per the schema/entity bean.

Though the process of generating an entity bean is automated for EJB, I still have to code the Session bean manually. If the database has a huge number of tables and I need to retreive information from most of them, coding a session bean may take a very long time.

Is there any way I can automate the code generation of Session Bean ?
or may be some effective mapping technique where I can write the application based on an abstract database schema and later on map it to the real database schema ?
Any other suggestions ?

   <<Less

Re: Automate generation of Session Bean

Posted By:   Tim_Frith  
Posted On:   Thursday, October 18, 2007 02:55 PM

You could look at creating some views that return the same columns in each database. Your EJBs then wouldn't care which database they were using. For example, every database would have a view that returned "employee email", "employee id" and "name" and the EJB wouldn't have to know which tables that view gathers the info from.


But you still have to write the views for each database. Which is easier for you - writing session beans for each or writing views for each?


Also, this approach would only work for retrieval, not insert/update.

About | Sitemap | Contact