aspose file tools*
The moose likes Websphere and the fly likes About Re-Generate Entity Beans (CMP) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "About Re-Generate Entity Beans (CMP)" Watch "About Re-Generate Entity Beans (CMP)" New topic
Author

About Re-Generate Entity Beans (CMP)

xin wen
Ranch Hand

Joined: Oct 11, 2002
Posts: 64
Hi All, I am using WSAD 4.0, and I have an EJB project with ten Entity Beans (CMP) in it. For some reason I changed one of my database table, so I need to re-generate that entity bean, however, WSAD did not allow me to do it? I do not know why this happened? Do I have to start a new project to do this, which will be so painful! Does anybody know something about this, please help! By the way, will WSAD 5.0 solve this kind of problem?
Thank you all a lot!
ping he
Greenhorn

Joined: Jan 02, 2003
Posts: 7
Hi
ping he
Greenhorn

Joined: Jan 02, 2003
Posts: 7
Hi
Did you delete the previous generated classes(Generate -> Deploy and RMIC code).
xin wen
Ranch Hand

Joined: Oct 11, 2002
Posts: 64
Thanks for reply Ping He!
Yes, I deleted all deployed code, when I tried to re-generate the entity bean by using Generate -> EJB to RDB Mapping..., and it won't let me re-generate, and instead, it will show me the Map.mapxmi file. Do you know how to solve this?
Thanks a lot!
Jay Damon
Ranch Hand

Joined: Jul 31, 2001
Posts: 279
What exactly did you change in your CMP beans? If all you want to do is regenerate deployment code, you should select Generate >> Deploy and RMIC code. The only reason to enter the mapping editor would be if you added or deleted a CMP field. If you added a field, you need to map the field in the CMP bean to the column in the table using the mapping editor. If you deleted a field, just open the mapping editor and then save. The mapping editor will recognize the "bad mapping", i.e. the field that no longer exists, and delete the mapping for you. Note that after changing a field mapping you must also regenerate deployment code.
[ February 06, 2003: Message edited by: Jay Damon ]
xin wen
Ranch Hand

Joined: Oct 11, 2002
Posts: 64
Thanks Jay Damon.
I added a new column to one of my tables, and also I added another new table to my database, I want to generate it, so am I able to generate it in the same EJB project?
Thanks
Jay Damon
Ranch Hand

Joined: Jul 31, 2001
Posts: 279
The answer is yes, but. . .
Adding a new field attribute to a CMP EJB for a new column in a table is easy. Open the EJB deployment descriptor, click on the Beans tab, and add the attribute there. That takes care of the EJB. Then, you must add the column to the corresponding .tblxmi file (which should be under META-INF/Schema in your EJB project). Open the .tblxmi file for your table, click on the Columns tab, and click Add Another (refer to similar columns in your tables to determine the column type and length). That takes care of the table. The last step is to open the EJB to RDB mapping editor, i.e. Map.mapxmi, and map the new EJB field attribute to the new table column. After opening the mapping editor, scroll down, find the Enterprise Bean (on the left) and double-click to find the corresponding Table (on the right). Open (click on the '+') both the EJB and Table. Drag and drop the field from the EJB field to the Table column (you could also right-click and select Match by Name if the names are the same). That's it. All you need to do now is to regenerate deployment code.
I'm afraid adding a table is not as easy. I am currently in a discussion with Kyle Brown in the EJB forum regarding this so you may want to look there also. Initially, create the a new entity EJB for the new table with the required field attributes. Then, the simplest solution, assuming your EJB field attributes are named the same as your table columns AND you have NO foreign keys in your database, is to generate a new Schema, replacing the one in the META-INF/Schema folder of your EJB project. To do so, perform a Generate >> EJB to RDB mapping and select Meet-in-the-middle.
If your fields are NOT named the same OR you have foreign keys in your tables, reply and I will elaborate some more.
xin wen
Ranch Hand

Joined: Oct 11, 2002
Posts: 64
Thanks Jay Damon,
that's really helpful!
Jay Damon
Ranch Hand

Joined: Jul 31, 2001
Posts: 279
FYI, the trick, I've learned, for adding a table is that you have to use the Data Perspective >> Data View. However, manually editing of the XML files may still be required. See also this EJB forum question for more info.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About Re-Generate Entity Beans (CMP)
 
Similar Threads
Deploying WSAD 4.0 application to WAS 5.0
How to map to a new database?
Adding a new CMP entity bean in WSAD5.0
Adding new Entity Bean in the existing application
Spec Chapter 12 -- BMP Entity Bean, no need for SCBCD?