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 235026 - Entity from Database wizard does not play well with existing persistence.xml
Summary: Entity from Database wizard does not play well with existing persistence.xml
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Persistence (show other bugs)
Version: 7.4
Hardware: All All
: P3 normal (vote)
Assignee: Sergey Petrov
URL:
Keywords:
Depends on: 235203
Blocks:
  Show dependency tree
 
Reported: 2013-08-26 12:02 UTC by Petr Jiricka
Modified: 2013-09-06 11:09 UTC (History)
0 users

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 Petr Jiricka 2013-08-26 12:02:32 UTC
1. Create a Java EE 7 application (with GF 4 target)
2. Create a persistence unit, do not specify the data source (according to EE 7 spec, java:comp/DefaultDataSource is assumed in such case)
3. Go to Entity from Database wizard

=> Problem 1: I would expect that the Data Source field would offer the data source corresponding to java:comp/DefaultDataSource, but that's not the case

4. Select the jdbc/sample datasource that's present in the combo box
5. Select some tables, specify package in the next panel and finish the wizard

=> I would expect that a new persistence unit corresponding to the selected datasource will be added to persistence.xml.
Comment 1 Petr Jiricka 2013-08-30 07:48:36 UTC
I am trying this with latest build that contains Tomas's hotfix for bug 235203, and here are my observations:

- Entity from Database wizard offers comp/DefaultDataSource - good
- Persistence Unit wizard offers comp/DefaultDataSource - good
- When I do steps 1-3, comp/DefaultDataSource is present in the combo box, but it's not preselected, it would be nice to preselect it
- When I select it, the New Database Connection wizard pops up, offering me to register sun-appserv-sampes database connection, which is not registered by default - looks like this is by design
- I go through the New DB Connection wizard and it works fine
- When the IDE returns be to the Entity from DB wizard and comp/DefaultDataSource is selected, the tables are not populated - looks like a refresh problem; the workaround is to restart this wizard
- When I do steps 1 and 3 (skipping step 2) from the initial description, and select create entities against comp/DefaultDataSource datasource, the IDE puts the following into persistence.xml:
<jta-data-source>comp/DefaultDataSource</jta-data-source> - this is not incorrect, but could be omitted as it's assumed by default
Comment 2 Sergey Petrov 2013-08-30 08:51:01 UTC
ok, so {1} remains as "preselect default ds", but current behaviour do not preselect also "jdbc/__default" if its' not yet properly registered withing ide,  otherwise user will get a dialog right after click next.

regarding {2} it's not an issue, user use current pu but generate entities from another resource to use with current pu, it works as designed. it may be new option to add new pu here but we remove any pu options from the wizard except creation and only in case of completely absent of any pu.
Comment 3 Sergey Petrov 2013-08-30 15:28:11 UTC
now, if connection was once registered default datasource is preselected
http://hg.netbeans.org/web-main/rev/53368171f5c3
Comment 4 Quality Engineering 2013-08-31 01:30:16 UTC
Integrated into 'main-silver', will be available in build *201308310001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/53368171f5c3
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: #235026 preselect default in empty case
Comment 5 Sergey Petrov 2013-09-02 05:31:16 UTC
Petr, is there anything to fix in this issue, do you want to add "add one more pu" functionality to the wizard in addition to current "create new persietence.xml with pu" and "use existent pu"?
Comment 6 Petr Jiricka 2013-09-02 09:37:57 UTC
> now, if connection was once registered default datasource is preselected
> http://hg.netbeans.org/web-main/rev/53368171f5c3

Thanks. One question, what's the behavior for EE 6? Is it the same, or different from EE 7?

> Petr, is there anything to fix in this issue

I would not do anything for NB 7.4 - it's now too close to code freeze and we don't have a clear idea of the desired behavior. Maybe not even after 7.4 - it may not make sense to complicate the UI just to make minor improvements in the behavior. What do you think, should we just leave it as it is now?
Comment 7 Sergey Petrov 2013-09-02 10:08:10 UTC
designed was - use pu if exist/no modification/no addition etc.
or create new pu if no one exist.

for ee6 as it's said above (just try to specify "jdbc/__default" in pu) and it will be preselected if connection is registered and will not be preselected if connection isn't registered, in my opinion it's one of possible designs.
Comment 8 Sergey Petrov 2013-09-06 11:09:14 UTC
for now, preselection in case it was supported for other datasources is added, but feel free to reopen if we may want to do more here.