This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
When creating entity beans from database, beans are named after the table. if a bean with that name exists, the IDE creates new bean and attaches '1' to the bean name. also, the IDE automatically creates beans for all referenced tables. There could be some indication of which tables are referenced/which beans will be created. for example: I have a database with 3 tables (Tables A, B, and C) TableA does not reference any other tables TableB and TableC reference each other and TableA 1. I create EJB module 2. I create a new entity bean from from Database and go through the wizard and choose TableA. There is no indication that other tables reference this table so i do not know 3. The IDE creates the bean TableA and i add some methods. 4. I then realize that I need TableB so i choose create new entity bean from database and in the wizard I choose TableB. 5. The IDE creates entity beans TableB and TableC, and it also creates the bean TableA1. So now i have 4 beans: TableB, TableC, TableA and TableA1. I think that this could be confusing situation. TableA bean references different dbschema, so now there are 2 schema in project. can the first schema be deleted without any problem? what if some code has already been added to the first bean(s). I think there should be some warning in wizard that a bean with that table name already exists and the IDE is creating a new entity bean and attaching a '1' after the name. If there is no warning or there can be no warning about the new bean with name similar to an existing name, and the appearance of a second dbschema, then it needs to be documented/stressed that new cmp from entity beans should maybe be done only once, after which beans need to be created and mapped manually (if that is true and there is no workaround)
I don't think you should end up with 2 dbschemas in this case - can you confirm? Because, beans in a single project can use different dbschemas only if there are no relationships b/w them. The fact that there are references b/w the tables makes me think there would be relationships b/w the beans....
the issue is more that if the developer creates cmp from db, and then later realizes some tables/beans are missing (because they did not reference those tables, though they were referenced by other tables) and uses the cmp from db again, new entity beans and a new schema are created, which could be confusing. i just tested again using the cmproster example from j2ee for netbeans tutorial. i created db. i then did create cmp from db, but instead of selecting all 4 tables, i only selected player. result: 1 entity bean, 1 db schema realizing that not all the necessary beans were created, i did cmp from db again, this time choosing team_player table. result: LeagueEB, Team EB and Player1EB and new schema PBPUBLIC_Roster_1.dbschema The Project now has 2 db schema (1 has only one table, the other has all four tables) my suggestion is that there should be some documentation and probably also some dialog about the dbschema and the bean with the name already existing in the project.
The first page of the EJB from DB wizard lets you point at a schema (in fact, I believe that's the default). If you do that, and point at the existing schema, do you have this problem?
if i create beans from cmp, the IDE generates the schema in the project. but the schema only has tables from referenced tables. eg if player table doesnt reference any tables (though team table does reference player table), then the only table in the dbschema is player. so if in the wizard i select the existing schema generated when i created the cmp from db, the only table listed is the player table.
Okay, I understand. You could either: 1) recapture the schema first with more tables 2) do what you said below, then delete the first A bean and refactor->rename the new A1 to A. There is definitely room for improvment here: 1) An enhancement request to have the wizard show a summary page of what beans will be generated so you don't have this problem 2) A request to have a warning/info dialog when a new A bean (A1) is being created. In this case, asking the user whether or not he wants to use that existing A instead wouldn't be so straightforward - the relationships b/w the beans and the mapping of the beans would be incorrect without a lot of extra changes.
This is fixable in 5.0, time permitting. The fix would be to skip generation of beans that already exist, we would do some simple heuristic to guess if the bean that exists really represents the table we think it represents, connect the links to this bean and issue a warning.
I already spent some time on this. My idea was: 1) check if dbschema for selected connection exists 2) if yes generate missing tables to schema 3) generate beans from schema as usually I am not sure if it is possible, but I'll try.
Too risky to fix now I think. Many possible regressions. It will be easy fix for promo-g if we will skip dbschema. Sorry.
TM 5.0 -> TBD
We thought about it in 5.5, but in the end there was no time to do it. The idea was to find the tables in the database which are already mapped to beans (that is, beans have been already generated for them) and disable them in the wizard, and also to avoid generating beans for already mapped tables (the same way it works for JPA entity classes).
Do we still need to spend time supporting the recreation of CMP beans? I guess we should rather focus on JPA entity classes, so closing this issue. If you reopen, do you think this still is a P3 issue?
I will not reopen. I do not see many postings regarding this issue, or other cmp issues. Agree that resources could be applied better than on fixing this issue.