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 217853 - Creating entities from schema uses wrong connection for persistence unit
Summary: Creating entities from schema uses wrong connection for persistence unit
Status: VERIFIED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Persistence (show other bugs)
Version: 7.3
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Sergey Petrov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-05 07:18 UTC by mienamoo
Modified: 2012-10-04 09:20 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 mienamoo 2012-09-05 07:18:27 UTC
NetBeans build 201209020001
JDK 7u5 64-bit

Background: I have two database connections. The first is the sample Derby DB, and the second is our actual development database.

I created a schema containing some tables from our dev database, and then I created entities from that schema. In the "New Entity Classes from Database" wizard, I checked the "Create Persistence Unit" option. But the persistence unit that was created pointed to the first database it found (which is the Derby DB) and not the database that the schema was generated from. So either ensure that the right connection is used somehow or allow the user to choose a connection as well.
Comment 1 mienamoo 2012-09-05 07:25:11 UTC
Oh, and all of this creation happened in a Maven-based NetBeans Platform application module.
Comment 2 Jaroslav Havlin 2012-09-27 09:41:45 UTC
Sergey, please, can you evaluate this issue?
I've tried to reproduce it, but persistence unit was created correctly for me.
Comment 3 Sergey Petrov 2012-09-27 09:50:15 UTC
yes, as there is no connection selection step, pu is created with some default value in this case it's first available connection. not sure what to do as we decide to avoid this extra step in the wizard and it's @by design@.
Comment 4 mienamoo 2012-09-27 09:56:35 UTC
Maybe as a compromise show the selection step only if there is more than one connection?

It makes sense to keep the wizard as simple as possible, but personally I would prefer seeing an extra step to ending up with a persistence unit that doesn't work.
Comment 5 Sergey Petrov 2012-09-27 10:37:30 UTC
one more possible solution may be persistenmce.xml editor can be opened if pu was created by this wizard, so it will be more visible what connection is used and can be corrected right after creation.
Regading steps this step is required only for generation from schema because in case of generation from datasource/connection this connection is used and it should fit most cases proper;y.
Comment 6 mienamoo 2012-09-27 10:52:11 UTC
(In reply to comment #5)
> one more possible solution may be persistenmce.xml editor can be opened if pu
> was created by this wizard, so it will be more visible what connection is used
> and can be corrected right after creation.

That would indeed help. :)

> Regading steps this step is required only for generation from schema because in
> case of generation from datasource/connection this connection is used and it
> should fit most cases proper;y.

Agreed.
Comment 7 Sergey Petrov 2012-10-02 09:56:15 UTC
fix with persistence.xml opening (only in case if it's created and if schema was used) http://hg.netbeans.org/web-main/rev/4f7616e8a332
may not be a complete or perfect fix but it may make functionality here a bit better
Comment 8 Quality Engineering 2012-10-03 02:43:24 UTC
Integrated into 'main-golden', will be available in build *201210030002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/4f7616e8a332
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: #217853 open persistence.xml
Comment 9 mienamoo 2012-10-04 09:20:13 UTC
Verified with build 201210040002 that the persistence.xml file is indeed opened.