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.
The information about the entity generated by the EntitiesFromDBGenerator is not immediately in the model. Moreover, there is no clean way to wait for the entity to appear in the model. The enity should either appear in the model immediately or there should be some listener or wait method.
IMHO the current implementation (where the model is notified about a new entity via detour through Retouche) is not ideal. I would prefer a solution where the generator notifies the model about the changes directly. It would significantly improve the performance of Matisse-related use-cases. I am also afraid that the current implementation will not work well if the entity is created when Retouche is busy (e.g. scanning JDK or project).
Right, I am currently considering either waiting for Retouche to compile the file, or introducing a method like ensureTypeScanned() somewhere in the model which could be used to notify that a type needs to be scanned and added to the model. Re. busy Retouche: that is probably a problem no matter which approach is chosen. I want to avoid calling JavaSource.runUserActionTask() while scanning, even if I go the notification way. By the way, you should avoid using the model if it's not ready (which it will claim is not during a scan). There is no API for that yet, but I plan to add one after M9. MetadataModel.isReady() or something like that, and also MetadataModel.waitReady() or such. You will need to use these methods in your wizard (and avoid entering the model context in the AWT thread, which you are currently doing).
This requires some changes in the Java infrastructure, not for M10. When these changes are implemented, the right way to ensure that the entity classes are in the model will be to use MetadataModel.runReadActionWhenReady() instead of runReadAction(). This methods waits for the classpath scan to finish, so you need to use it consistently everywhere.
There is a similar issue in the EJB model, adding an EJB annotation to a newly created class does not make it appear in the model even if you use the runReactionWhenReady method.
Marking as enhancement to match issue 108649, which this depends on. Still planning to fix after beta 2.
Is this still valid issue or not? I'm trying to figure out whether something needs to be done for next release but looking into code everything seems to be working well: api.java.source.ClassIndexListener changes are fired immediately after a changed source was saved; and MetadataModel.runReadActionWhenReady can be used to run something after scanning was completed. Can anybody say what's still missing or broken? Thanks.
Cau Davide, the problem should be fixed. In the NB 6.0-6.5 there was a delay between save and update, because of timestamps. In the NB 6.7 i've rewritten to use other timestamp storage and there is no more such a delay.
Thanks Tomas. It looked like that.