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 141509 - Wrong generated query in JDA project with db
Summary: Wrong generated query in JDA project with db
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Project (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: Tomas Zezula
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-24 11:07 UTC by Jana Maleckova
Modified: 2008-07-31 14:21 UTC (History)
9 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
141509 (4.62 KB, text/plain)
2008-07-24 11:13 UTC, Jana Maleckova
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jana Maleckova 2008-07-24 11:07:47 UTC
Product Version: NetBeans IDE Dev (Build 20080724040119)
Java: 1.6.0_10-rc; Java HotSpot(TM) Client VM 11.0-b13
System: Windows XP version 5.1 running on x86; Cp1252; en_GB (nb)

Description:
============
Start IDE and try to generate JDA project with db connection and check query which is set in view class ... 
there is default string which is not correct : SELECT o FROM Object o
but if I change it to proper query string then project can be run but no data are loaded in table from db. There seems
to be deeper problem.
The layout of view class is generated incorrectly as well. It doesn't contain textfields as usual.

Another issue appears when I try to generate Project with Master/Detailed Table. But It could be the consequence of
previous one.
The results are:
view class is generated with compilation errors, query is wrong and during creating of project NPE is thrown which comes
from j2ee module. 
I can't evaluate if this is a form or j2ee issue, so please reassign it to appropriate component if needed.

StackTrace:
===========
java.lang.NullPointerException
        at
org.netbeans.modules.j2ee.persistence.wizard.fromdb.JavaPersistenceGenerator$Generator$EntityClassGenerator.generateRelationship(JavaPersistenceGenerator.java:911)
        at
org.netbeans.modules.j2ee.persistence.wizard.fromdb.JavaPersistenceGenerator$Generator$ClassGenerator.run(JavaPersistenceGenerator.java:657)
        at
org.netbeans.modules.j2ee.persistence.wizard.fromdb.JavaPersistenceGenerator$Generator$1.run(JavaPersistenceGenerator.java:422)
        at
org.netbeans.modules.j2ee.persistence.wizard.fromdb.JavaPersistenceGenerator$Generator$1.run(JavaPersistenceGenerator.java:419)
        at org.netbeans.api.java.source.JavaSource.runModificationTask(JavaSource.java:916)
Comment 1 Jana Maleckova 2008-07-24 11:13:58 UTC
Created attachment 65509 [details]
141509
Comment 2 Jan Stola 2008-07-24 14:12:48 UTC
The described problems (e.g. incorrectly generated Java Desktop application) are caused
by the fact that newly generated entity doesn't appear in the model
e.g. EntityMappingsMetadata.getRoot().getEntity() returns an empty array.

I am not able to evaluate the attached exception, but I believe that it will have the same root as the problem with 
EntityMappingsMetadata.getRoot().getEntity().

Reassigning to j2ee/persitence for evaluation.
Comment 3 Dongmei Cao 2008-07-24 22:54:18 UTC
For the NPE, I do have another bug 139804 reported. But I'm not able to find a reproducible case for it. Honza, can you
help me reproduce issue 139804? Thanks.

Also, I can not even make a compilable JDA with table from a yesterday's build. Is this thing working at all?
Comment 4 Dongmei Cao 2008-07-25 03:17:45 UTC
Ok, I see the NPE on the console all the time now, which is breaking the whole application. But I still don't understand
why it is happening. I tried the same application in M1, it worked fine. The Web applications also work fine in the
latest code. The NPE is from when trying to generate the relationship field, it can not find the TypeElement of the
other class (workingCopy.getElements().getTypeElement("the.class.on.the.other.side.of.relationship") returns null). Is
this a JavaSource issue?
Comment 5 Andrei Badea 2008-07-25 09:54:05 UTC
Perhaps a compile on save issue?
Comment 6 Andrei Badea 2008-07-25 12:55:58 UTC
No, it looks caused by the fix of issue 67270. The entity and related artifacts in the JDA project are generated while
the project is being opened. If they were generated before opening the project, the project's sourcepath wouldn't be
registered in GlobalPathRegistry and there would be no ClassIndex events for the generated entity, or the entity
wouldn't be in ClassIndex at all, not sure now.
Comment 7 Tomas Zezula 2008-07-25 15:51:45 UTC
Nice try Jardo.
The GlobalSourcePath is my class however the code causing regression was your contribution.
Comment 8 Dongmei Cao 2008-07-25 15:54:39 UTC
Thanks, Andrei, for looking into it!
Comment 9 Tomas Pavek 2008-07-25 16:22:08 UTC
Jarda will be OOO for next week. Tomas, any idea what could get wrong? You've seen the patch. The only change in 
fixing 67270 was that GlobalPathRegistry now fires later - i.e. after the project is opened (also after open project 
hook), but the content of all paths should be ok (all paths registered, just not fired - if I understand it right). 
Maybe Andrei could comment on that?

Anyway, if this is tricky to be sorted out, can someone rollback the change until Jarda is back? Thanks
Comment 10 Tomas Zezula 2008-07-25 16:26:08 UTC
The problem is that form in the OpenProjectHook accesses metadata which are delayed by Jarda patch to the end of the OpenProjectHook.
Comment 11 Tomas Zezula 2008-07-25 16:27:52 UTC
Either form will change the code it generated the java code (I have no idea how yet) or the Jarda's patch needs to be rolled back.

Comment 12 Tomas Zezula 2008-07-25 19:57:19 UTC
If there are no objections I suggest to rollback the performance improvement causing this problem.

Comment 13 Marian Mirilovic 2008-07-28 12:15:08 UTC
Ok, Tomas who is going to rollback Yarda's changes ?
Comment 14 Antonin Nebuzelsky 2008-07-28 12:22:50 UTC
Agreed with Tomas that he will rollback the Jarda's change.
Comment 15 Tomas Pavek 2008-07-30 09:43:06 UTC
After discussions fixed in GUI builder.
http://hg.netbeans.org/main/rev/f2063fd3901f
Comment 16 Jana Maleckova 2008-07-31 14:21:53 UTC
verified on

Product Version: NetBeans IDE Dev (Build 20080731042603)
Java: 1.6.0_10-rc; Java HotSpot(TM) Client VM 11.0-b13
System: Windows XP version 5.1 running on x86; Cp1252; en_GB (nb)