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 136037 - incorrect code generation - entityManager
Summary: incorrect code generation - entityManager
Status: RESOLVED INVALID
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Binding (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-05-28 20:08 UTC by barryc
Modified: 2008-06-05 08:36 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description barryc 2008-05-28 20:08:53 UTC
Dragging an Oracle database table name from services to a jcomboBox generates an entityManager, a query and a list.
It also generates the following line of code:
        providerQuery = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT  t FROM table_name t");
This will run, but the addition of a where clause causes it to crash with the error "An exception occured while creating
a query in EntityManager"
The correct code should use  entityManager.createNativeQuery.
Because this is IDE generated code, it is uneditable from within Netbeans and any fiddling with the Query component
causes the loss of the corrected code.
Comment 1 Peter Pis 2008-05-29 12:39:04 UTC
Reassigning to "db" for evaluation.
Comment 2 David Vancouvering 2008-06-03 17:56:19 UTC
Reassigning to persistence - sorry I didn't do this sooner, I was not paying attention to my unevaluated list :(
Comment 3 Dongmei Cao 2008-06-04 23:06:10 UTC
The code is not directly generated from persistence module. Send to form/binding for evaluation.
Comment 4 Jan Stola 2008-06-05 08:36:06 UTC
It is not

> entityManager.createQuery("SELECT  t FROM table_name t");

but entityManager.createQuery("SELECT  t FROM entity_name t");
e.g. the argument is not SQL query, but JPA query. Hence, it is correct to use createQuery, not createNativeQuery.

I don't know why is your application failing in query creation, but an incorrect selection of createQuery method is not 
the reason.