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 74113 - New Entity from DB wizard has no default datasource selected
Summary: New Entity from DB wizard has no default datasource selected
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Persistence (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker (vote)
Assignee: Andrei Badea
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-28 22:36 UTC by Rochelle Raccah
Modified: 2006-08-10 09:22 UTC (History)
3 users (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 Rochelle Raccah 2006-03-28 22:36:34 UTC
To me, this is a regression compared to the old wizard, especially if I have a
dbschema in the project.  I know there is a bit more overhead in db connection,
but in the case of a dbschema, it really just involves reading the file, not a
db sconnection.  Also, if I open the wizard twice in a row, it should remember
my last selection - in that case, there won't be a connection overhead because
the connection should have happened last wizard session.
Comment 1 Andrei Badea 2006-03-29 09:24:09 UTC
OK, if there is a dbschema in the project, it can be deserialized and selected
in the combo box when the wizard is opened. But if there isn't, according to the
UI spec you would have to select the first connection *and* display its
connection dialog. When you right-click the project and select the wizard, not
only the wizard would pop up, but also the connection dialog on top of the
wizard. I don't like this, but will do it if Jano says so. Reassigning to him
for comments.

Re. remembering the last schema: I would remember the last table source
selection for the current IDE session, but I woulnt' serialize this info to disk
(looks like too much work for too little gain).
Comment 2 Rochelle Raccah 2006-07-12 00:48:54 UTC
Jano, can you update this with what should be done?
Comment 3 jrojcek 2006-07-18 14:13:21 UTC
Initially (using the wizard for the first time):

- If there's a schema file in project, we should select it in the combo box. 
- If there's no schema, we should not select schema, nor connection.

Next time:

- If a schema file was selected previously, we should select it for the user.
- If a connection was selected, then it would be good to select it, but only if we remember the 
password. Otherwise, do not select anything.

Okay?

It's a pity that it's a lot of work to remember things across IDE sessions. Because if we remember 
something between different wizard invocation, we should remember it also between IDE sessions.
Comment 4 Andrei Badea 2006-07-28 15:25:17 UTC
Okay.
Comment 5 Andrei Badea 2006-08-03 16:14:29 UTC
Hopefull fixed.

Checking in persistence/nbproject/project.xml;
/cvs/j2ee/persistence/nbproject/Attic/project.xml,v  <--  project.xml
new revision: 1.1.2.16.2.14; previous revision: 1.1.2.16.2.13
done
Checking in
persistence/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/DatabaseTablesPanel.java;
/cvs/j2ee/persistence/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/Attic/DatabaseTablesPanel.java,v
 <--  DatabaseTablesPanel.java
new revision: 1.1.2.33; previous revision: 1.1.2.32
done
Checking in
persistence/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/EntityClassesPanel.java;
/cvs/j2ee/persistence/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/Attic/EntityClassesPanel.java,v
 <--  EntityClassesPanel.java
new revision: 1.1.2.19; previous revision: 1.1.2.18
done
Checking in
persistence/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/RelatedCMPHelper.java;
/cvs/j2ee/persistence/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/Attic/RelatedCMPHelper.java,v
 <--  RelatedCMPHelper.java
new revision: 1.1.2.2.2.8; previous revision: 1.1.2.2.2.7
done
Checking in
persistence/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/RelatedCMPWizard.java;
/cvs/j2ee/persistence/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/Attic/RelatedCMPWizard.java,v
 <--  RelatedCMPWizard.java
new revision: 1.1.2.2.2.20; previous revision: 1.1.2.2.2.19
done
RCS file:
/cvs/j2ee/persistence/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/Attic/TableSource.java,v
done
Checking in
persistence/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/TableSource.java;
/cvs/j2ee/persistence/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/Attic/TableSource.java,v
 <--  TableSource.java
new revision: 1.1.2.1; previous revision: 1.1
done
RCS file:
/cvs/j2ee/persistence/test/unit/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/Attic/TableSourceTest.java,v
done
Checking in
persistence/test/unit/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/TableSourceTest.java;
/cvs/j2ee/persistence/test/unit/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/Attic/TableSourceTest.java,v
 <--  TableSourceTest.java
new revision: 1.1.2.1; previous revision: 1.1
done
Checking in utilities/manifest.mf;
/cvs/j2ee/utilities/manifest.mf,v  <--  manifest.mf
new revision: 1.6.2.3.2.9; previous revision: 1.6.2.3.2.8
done
Checking in utilities/src/org/netbeans/modules/j2ee/common/DatasourceHelper.java;
/cvs/j2ee/utilities/src/org/netbeans/modules/j2ee/common/Attic/DatasourceHelper.java,v
 <--  DatasourceHelper.java
new revision: 1.1.2.3; previous revision: 1.1.2.2
done
Comment 6 Rochelle Raccah 2006-08-03 19:54:22 UTC
This is a huge improvement!  My only concern is in trying the connection and
having the connection automatically selected the next time.  This results in 2
identical dbschemas unless there was a change in the database itself.  Is that
really what we want?
Comment 7 Andrei Badea 2006-08-04 09:19:25 UTC
Yeah, good catch. I guess this is a question for Jano.
Comment 8 jrojcek 2006-08-04 11:17:27 UTC
I don't understand why there are 2 identical schemas in that scenario.
Comment 9 Andrei Badea 2006-08-04 12:24:32 UTC
You invoke the wizard for the first time in an EJB project. No data source is
selected. You select jdbc/sample, add some but not all tables and finish the
wizard -- a dbschema file is generated. You invoke the wizard for the second
time. The jdbc/sample data source is selected, since it was used in the previous
invocation. You are happy you see the tables already displayed, so you add those
you haven't added in the previous invocation and finish the wizard -- a new
dbschema file is generated, having the same contents as the first one unless the
database changed in the meanwhile.
Comment 10 jrojcek 2006-08-04 14:47:43 UTC
I see. I think the fact that we silently generate multiple schema files is quite bad. After discussion with 
Andrei, it looks like maybe we don't have to generate schema file, but we don't know all the reasons why 
we generate them currently. Maybe because of CMP beans? Pavle, could we get rid of generating the 
schema file as part of "Entity Classes from DB"?
Comment 11 Pavel Buzek 2006-08-04 16:08:32 UTC
I do not see why we would need to generate a new schema every time. I think it
is a bug, we should just update the existing schema for that DS/connection if it
exists.
Comment 12 Andrei Badea 2006-08-04 17:27:43 UTC
It's hard to say if it is a bug when there is no specification and we don't know
what is the intended behavior. Anyway, if we wanted to do it, the result should
be the equivalent of invoking Recapture Schema on the dbschema file before
invoking the wizard, right?

I slightly don't like the idea of iterating over and loading all dbschema files
in the project in order to find one which matches the database connection. Could
have performance implications, but probably usually not, since by this we
actually keep the number of the dbschema files in the project small.
Comment 13 Pavel Buzek 2006-08-04 18:07:47 UTC
Yes, I think it should do the same as "recapture schema". If we update the
existing schema instead of creating a new one every time you run the wizard then
there will only be one schema per connection. Unless the user created one
manually which I think is not typical (and if they did we would at least find
and update it from the wizard). Using more then one connection is also quite
rare case, IMHO. So hopefully there will be almost zero performance impact in a
typical case.

Generating files that are of no use is IMO a bug. Not a huge deal but at least
it looks strange.
Comment 14 Andrei Badea 2006-08-04 18:18:51 UTC
Filed issue 81956.
Comment 15 Rochelle Raccah 2006-08-05 00:46:29 UTC
Another unexpected behavior:
Say I have a dbschema file in mypackage and right click on that package to
invoke this wizard.  The first found schema in META-INF is the default, not the
one in my package.
Comment 16 Rochelle Raccah 2006-08-09 23:25:52 UTC
Jano, can you comment on my last concern?
Comment 17 Pavel Buzek 2006-08-09 23:34:10 UTC
Never add "another concern" into an existing issue. One issue, one problem. If
you reopen you know what problem you want to revisit, every issue has its own
priority, etc. If you have another problem (or a concern) file a new issue. I am
not surprised Jano does not pay attention to resolved issues - yet another
reason to file a new one.
(BTW, IMO your concern is a P5)
Comment 18 Rochelle Raccah 2006-08-09 23:36:49 UTC
I was trying to get Jano's advice on whether to reopen or file a diff issue 
=).  I'll file a separate one, though I think it's p4.
Comment 19 Rochelle Raccah 2006-08-09 23:38:41 UTC
filed as issue 82325
Comment 20 jrojcek 2006-08-10 09:22:57 UTC
I agree that selection of initial schema file could look into the selected package first. Thank you for filing a 
new issue.