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 195974 - RESTfulWS from DB wizard creates JPA 2 persistence.xml when it should generate JPA 1
Summary: RESTfulWS from DB wizard creates JPA 2 persistence.xml when it should generat...
Status: RESOLVED FIXED
Alias: None
Product: webservices
Classification: Unclassified
Component: REST (show other bugs)
Version: 7.0
Hardware: PC All
: P3 normal (vote)
Assignee: Denis Anisimov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-24 23:07 UTC by Jeffrey Rubinoff
Modified: 2011-02-26 05:14 UTC (History)
2 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 Jeffrey Rubinoff 2011-02-24 23:07:46 UTC
NB version: Dev 20110223
Java: 1.6.0_20
OS: Windows XP version 5.1 on x86
New, virgin userdir
Glass Fish 3.1 b43

Steps to reproduce:
1. Create a new EE6 Web Application that uses GF 3.1. Add the Spring framework
3.0.2
2. Run the RESTful WS from Database wizard. Use the Derby jdbc/sample data
source and the CUSTOMER table from that data source. 
3. Choose to generate a subclass of javax.ws.rs.core.Application for REST
resource application, with Jersey libraries added to classpath. (This doesn't
seem to matter, because web.xml is generated anyway.)
4. Add aopalliance.jar to the application's compile-time libraries. Also delete
the @Error annotations from the service classes.

The resulting persistence.xml file is for TopLink and should be for JPA 1.0. However, it is for JPA 2.0, which is not supported by Swing.

If you delete this persistence.xml and generate a new TopLink PU from the Persistence unit wizard, it is correctly version 1.0.
Comment 1 Denis Anisimov 2011-02-25 08:14:58 UTC
(In reply to comment #0)
> 
> The resulting persistence.xml file is for TopLink and should be for JPA 1.0.
> However, it is for JPA 2.0, which is not supported by Swing.
No it shouldn't.
This is just a workaround for known issue #179216.
It is normal to create persistence unit with new spec version.
Persistence unit is created and configured for project via call :
org.netbeans.modules.j2ee.persistence.wizard.Util.addPersistenceUnitToProject(project,org.netbeans.modules.j2ee.persistence.wizard.Util.buildPersistenceUnitUsingData(project, null, helper.getTableSource().getName(), null, null));

So please provide extending version of method in the Util class which allows 
choose persistence version to clients ( RESTful code ).
F.e. add method "buildPersistenceUnitUsingData" with additional argument which 
could have either boolean type or some enum type .
As result there will be two overloaded methods: with additional argument and 
without it.
In case of presence this additional argument the method should use its value to 
specify persistence version.
After providing this functionality on the j2ee.persistence module side please 
reassign this issue to the RESTful . I will use it for Spring workaround.
Comment 2 Sergey Petrov 2011-02-25 10:46:46 UTC
quite strange to use wrong api/spi, but if it's really necessry it's always
possible to extend. api/spi etc with "manual" version restriction may have
sense even for persitence itself if allow to limt version in new pu wizard but
there is no such functionality. will look.
Comment 3 Sergey Petrov 2011-02-25 12:58:38 UTC
http://hg.netbeans.org/web-main/rev/4304f7c33ed0 added version parameter, it's used as "restriction" not as direct version, you will not be able to create 2.0 in project with 1.0 support only, but should be able to create 1.0 in project with 2.0 support.
Comment 4 Denis Anisimov 2011-02-25 13:51:52 UTC
Thanks,
changeset:   189576:28947aa1303f
Comment 5 Quality Engineering 2011-02-26 05:14:59 UTC
Integrated into 'main-golden', will be available in build *201102260001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/4304f7c33ed0
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: fix #195974 extend api