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.

Bug 101909 - Entities didn't appear in the model until IDE restart
Summary: Entities didn't appear in the model until IDE restart
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Andrei Badea
URL:
Keywords: RANDOM
Depends on:
Blocks:
 
Reported: 2007-04-20 09:18 UTC by Jan Stola
Modified: 2007-05-07 14:10 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Events (8.85 KB, text/plain)
2007-04-20 11:29 UTC, Andrei Badea
Details
log file (134.13 KB, text/plain)
2007-04-25 19:55 UTC, Tomas Zezula
Details
RepositoryUpdater diff which fixes the java side and does logging (4.07 KB, patch)
2007-04-25 19:57 UTC, Tomas Zezula
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Stola 2007-04-20 09:18:31 UTC
When more than one entity is generated by the EntitiesFromDBGenerator then 
usually just one of them appear in the model. The second didn't appear in the 
model until the restart of the IDE.

Steps to reproduce:
1. Open or create some java project.
2. Create some package in the project (this is just a workaround for another
   issue - creation of a form together with a new package doesn't work well).
3. Open Master/Detail Form wizard (New File > Java GUI Forms > Sample Forms).
4. Specify name of the form and existing package on the first tab.
5. On the second tab: select DB connection to sample DB of GlassFish;
   select DISCOUNT_CODE table
6. On the third tab select Table choice and CUSTOMER table.
7. Press Finish.
8. Wait approximately 40s - we are waiting for both entities (DiscountCode
   and Customer) to appear in the model.

By now the Customer and DiscountCode entity classes are generated, but the 
model don't know about them. When I tried this use-case, just the DiscountCode 
entity was in the model, but Customer wasn't there. Note that it doesn't help 
to wait for even a longer time. The entity will not appear in the model until 
restart of the IDE.

Marking this issue as a high priority one because it makes Master/Detail wizard 
unusable (the generated form is not correct because we didn't have information 
about the entities).
Comment 1 Andrei Badea 2007-04-20 11:28:59 UTC
No "added" ClassIndex events seem to be sent for DiscountCode, only "changed"
events. Tomasi, could you please look at it? I can work around by checking if
changed types are entity classes (which I should do anyway), but still, the
"added" events should be sent too.

With the following diff to ClassIndexImpl

-----%<-----
Index: ClassIndexImpl.java
===================================================================
RCS file:
/cvs/java/source/src/org/netbeans/modules/java/source/usages/ClassIndexImpl.java,v
retrieving revision 1.4
diff -u -r1.4 ClassIndexImpl.java
--- ClassIndexImpl.java 11 Apr 2007 11:45:51 -0000      1.4
+++ ClassIndexImpl.java 20 Apr 2007 10:26:41 -0000
@@ -107,12 +107,15 @@
             ClassIndexImplListener l = lr.get();
             if (l != null) {
                 if (added != null) {
+                    System.out.println("added " + added.getTypes());
                     l.typesAdded(added);
                 }
                 if (removed != null) {
+                    System.out.println("removed " + removed.getTypes());
                     l.typesRemoved(removed);
                 }
                 if (changed != null) {
+                    System.out.println("changed " + changed.getTypes());
                     l.typesChanged(changed);
                 }
             }
-----%<-----

I obtained the attached log, which does not contain an "added" event for
DiscountCode.
Comment 2 Andrei Badea 2007-04-20 11:29:55 UTC
Created attachment 41329 [details]
Events
Comment 3 Tomas Zezula 2007-04-20 12:24:03 UTC
Don't you generate the classes by java.io.File?
Are the generated classes visible in the GoToType?
Comment 4 Andrei Badea 2007-04-20 14:05:21 UTC
The files are created using GenerationUtils, which uses
DataObject.createFromTemplate(). I assume that uses FileObject's, right?

Yes, both classes are visible in Go To Type.
Comment 5 Andrei Badea 2007-04-20 14:45:45 UTC
I just got "added" events for both classes during a debug session.
Comment 6 Andrei Badea 2007-04-23 10:21:34 UTC
Adding some logging and checking and adding new objects to the model also on
"changed" events. This needs to be done anyway, and in this case it also works
around the "added" events not being sent.

Checking in
j2ee/metadata/support/src/org/netbeans/modules/j2ee/metadata/model/api/support/annotation/AnnotationScanner.java;
/cvs/j2ee/metadata/support/src/org/netbeans/modules/j2ee/metadata/model/api/support/annotation/AnnotationScanner.java,v
 <--  AnnotationScanner.java
new revision: 1.3; previous revision: 1.2
done
Checking in
j2ee/metadata/support/src/org/netbeans/modules/j2ee/metadata/model/api/support/annotation/ObjectProvider.java;
/cvs/j2ee/metadata/support/src/org/netbeans/modules/j2ee/metadata/model/api/support/annotation/ObjectProvider.java,v
 <--  ObjectProvider.java
new revision: 1.3; previous revision: 1.2
done
Checking in
j2ee/metadata/support/src/org/netbeans/modules/j2ee/metadata/model/api/support/annotation/PersistentObject.java;
/cvs/j2ee/metadata/support/src/org/netbeans/modules/j2ee/metadata/model/api/support/annotation/PersistentObject.java,v
 <--  PersistentObject.java
new revision: 1.3; previous revision: 1.2
done
Checking in
j2ee/metadata/support/src/org/netbeans/modules/j2ee/metadata/model/api/support/annotation/PersistentObjectManager.java;
/cvs/j2ee/metadata/support/src/org/netbeans/modules/j2ee/metadata/model/api/support/annotation/PersistentObjectManager.java,v
 <--  PersistentObjectManager.java
new revision: 1.4; previous revision: 1.3
done
Checking in
j2ee/metadata/support/test/unit/src/org/netbeans/modules/j2ee/metadata/model/api/support/annotation/PersistentObjectManagerTest.java;
/cvs/j2ee/metadata/support/test/unit/src/org/netbeans/modules/j2ee/metadata/model/api/support/annotation/PersistentObjectManagerTest.java,v
 <--  PersistentObjectManagerTest.java
new revision: 1.4; previous revision: 1.3
done
Checking in
j2ee/persistenceapi/src/org/netbeans/modules/j2ee/persistenceapi/metadata/orm/annotation/EntityImpl.java;
/cvs/j2ee/persistenceapi/src/org/netbeans/modules/j2ee/persistenceapi/metadata/orm/annotation/EntityImpl.java,v
 <--  EntityImpl.java
new revision: 1.3; previous revision: 1.2
done
Checking in
j2ee/persistenceapi/src/org/netbeans/modules/j2ee/persistenceapi/metadata/orm/annotation/EntityMappingsImpl.java;
/cvs/j2ee/persistenceapi/src/org/netbeans/modules/j2ee/persistenceapi/metadata/orm/annotation/EntityMappingsImpl.java,v
 <--  EntityMappingsImpl.java
new revision: 1.4; previous revision: 1.3
done
Comment 7 Andrei Badea 2007-04-23 10:39:41 UTC
Previous commit had a commit log referring to issue 101719 instead of this one.
Committing again with the right commit log.

Checking in
j2ee/metadata/support/src/org/netbeans/modules/j2ee/metadata/model/api/support/annotation/AnnotationScanner.java;
/cvs/j2ee/metadata/support/src/org/netbeans/modules/j2ee/metadata/model/api/support/annotation/AnnotationScanner.java,v
 <--  AnnotationScanner.java
new revision: 1.5; previous revision: 1.4
done
Checking in
j2ee/metadata/support/src/org/netbeans/modules/j2ee/metadata/model/api/support/annotation/ObjectProvider.java;
/cvs/j2ee/metadata/support/src/org/netbeans/modules/j2ee/metadata/model/api/support/annotation/ObjectProvider.java,v
 <--  ObjectProvider.java
new revision: 1.5; previous revision: 1.4
done
Checking in
j2ee/metadata/support/src/org/netbeans/modules/j2ee/metadata/model/api/support/annotation/PersistentObject.java;
/cvs/j2ee/metadata/support/src/org/netbeans/modules/j2ee/metadata/model/api/support/annotation/PersistentObject.java,v
 <--  PersistentObject.java
new revision: 1.5; previous revision: 1.4
done
Checking in
j2ee/metadata/support/src/org/netbeans/modules/j2ee/metadata/model/api/support/annotation/PersistentObjectManager.java;
/cvs/j2ee/metadata/support/src/org/netbeans/modules/j2ee/metadata/model/api/support/annotation/PersistentObjectManager.java,v
 <--  PersistentObjectManager.java
new revision: 1.6; previous revision: 1.5
done
Checking in
j2ee/metadata/support/test/unit/src/org/netbeans/modules/j2ee/metadata/model/api/support/annotation/PersistentObjectManagerTest.java;
/cvs/j2ee/metadata/support/test/unit/src/org/netbeans/modules/j2ee/metadata/model/api/support/annotation/PersistentObjectManagerTest.java,v
 <--  PersistentObjectManagerTest.java
new revision: 1.6; previous revision: 1.5
done
Checking in
j2ee/persistenceapi/src/org/netbeans/modules/j2ee/persistenceapi/metadata/orm/annotation/EntityImpl.java;
/cvs/j2ee/persistenceapi/src/org/netbeans/modules/j2ee/persistenceapi/metadata/orm/annotation/EntityImpl.java,v
 <--  EntityImpl.java
new revision: 1.5; previous revision: 1.4
done
Checking in
j2ee/persistenceapi/src/org/netbeans/modules/j2ee/persistenceapi/metadata/orm/annotation/EntityMappingsImpl.java;
/cvs/j2ee/persistenceapi/src/org/netbeans/modules/j2ee/persistenceapi/metadata/orm/annotation/EntityMappingsImpl.java,v
 <--  EntityMappingsImpl.java
new revision: 1.6; previous revision: 1.5
done
Comment 8 Petr Jiricka 2007-04-23 14:25:19 UTC
The remaining part is up to Tomas, assigning to Java module.
Comment 9 Jan Stola 2007-04-23 15:01:51 UTC
*** Issue 102161 has been marked as a duplicate of this issue. ***
Comment 10 Tomas Zezula 2007-04-25 18:30:09 UTC
J1_STOPPER? Probably I've missed something. To reproduce this issue I have to
turn off "workaround" which is in the frozen trunk. So even if I fix this no one
in trunk or tomorrow on the branch will notice anything. Can you explain more
deeply what effect will have the fix on J1 build except of possible destabilization?
Comment 11 Tomas Zezula 2007-04-25 19:53:13 UTC
I've did some changes to prevent javac to generate more signature files +
logging. But it seems that problem is somewhere in model. See attached log file.
The TYPES_ADDED events are fired from ClassIndex for all the generated classes,
but the wizard crashes. It's strange that at the beginning there are 2
ClassIndexes and after while there are 4.
Comment 12 Tomas Zezula 2007-04-25 19:55:30 UTC
Created attachment 41660 [details]
log file
Comment 13 Tomas Zezula 2007-04-25 19:57:03 UTC
Created attachment 41661 [details]
RepositoryUpdater diff which fixes the java side and does logging
Comment 14 Petr Blaha 2007-04-25 20:16:58 UTC
I'm sorry, I thought that the issue isn't workarounded and should be fixed in
java module. In case nobody is able to reproduce in the latest daily build,
let's to downgrade, remove SW and fix after M9.
Comment 15 Tomas Zezula 2007-04-25 20:24:12 UTC
If Andrei's workaround works fine I will be rather not to integrate it into M9
since it seems that the fix is not isolated in single (java) module.
Comment 16 Petr Blaha 2007-04-25 20:29:08 UTC
jstola or jvagner can you check whether Andrei's workaround resolves the issue?
Thanks, Petr
Comment 17 Jiri Vagner 2007-04-26 07:57:05 UTC
Cool, now Master/Detail Form wizard works perfectly.

NetBeans IDE Dev (Build 20070426-0113)
1.6.0_02-ea; Java HotSpot(TM) Client VM 1.6.0_02-ea-b02
Linux version 2.6.17-10-386 running on i386
en_US (nb); UTF-8
Comment 18 Petr Blaha 2007-04-26 08:41:27 UTC
I suggest to downgrade the bug now since workaround works.
Comment 19 Tomas Zezula 2007-04-26 10:11:43 UTC
Workaround exists, decreasing priority.