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 234729 - persistence.xml version 2.1 without jta-data-source should default the datasource to java:comp/DefaultDataSource
Summary: persistence.xml version 2.1 without jta-data-source should default the dataso...
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Persistence (show other bugs)
Version: 7.4
Hardware: PC All
: P2 normal (vote)
Assignee: Sergey Petrov
URL:
Keywords:
Depends on: 235027
Blocks:
  Show dependency tree
 
Reported: 2013-08-21 14:36 UTC by Petr Jiricka
Modified: 2013-08-30 07:18 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-21 14:36:34 UTC
1. Open persistence.xml that uses version 2.1 and does not have the jta-data-source element
2. Switch to Design tab,make sure that the General section in the UI editor is expanded, and put caret in the Data Source field

=> Problem 1: In JPA 2.1, if jta-data-source is not specified, data source java:comp/DefaultDataSource is assumed, and server must provide this datasource. So the Data Source field should be prepopulated with java:comp/DefaultDataSource

=> Problem 2: Even if transaction-type="JTA" attribute on the persistence-unit element is specified, the "Use Java Transaction APIs" checkbox is unchecked

3. Switch back to Source tab

=> Problem 3: persistence.xml is modified: empty <jta-data-source/> or <non-jta-data-source/> element is added, and transaction-type is changed to RESOURCE_LOCAL.
Comment 1 Sergey Petrov 2013-08-26 11:12:56 UTC
Shou;d it really be prepopulated?

 As it can be either specified or omitted with the same result, it ay be two separate options. 
Also selection of this default may produce 2 different persistence.xml.

More general approach should involve server code to populate existed datasources list with this default.

3rd one is a real problem in my opinion. It may have no sense to specify jta-data-source with empty content and general fix may be to remove it if field is empty.
Comment 2 Petr Jiricka 2013-08-26 11:38:51 UTC
> Shou;d it really be prepopulated?

Maybe not, you are right. Leaving this empty is a possibility.

> 3rd one is a real problem in my opinion. 

I agree. #2 should be fixed too.
Comment 3 Petr Jiricka 2013-08-26 12:04:29 UTC
> Shou;d it really be prepopulated?

Though the default datasource should be taken into account in some other situations - see e.g. bug 235026 for the Entity from Database wizard.
Comment 4 Sergey Petrov 2013-08-26 13:49:27 UTC
it's a question if DefaultDataSource is available for applications with ee6 and lower level running on gf4 and why it's not listed in asadmin output.
Comment 5 Sergey Petrov 2013-08-27 13:43:55 UTC
http://hg.netbeans.org/web-main/rev/62d45444f9b8 fix for 2,3.

it's still a question if default datasource can be obtained common way as all others from server plugin from gf4 or it's required to hardcode it somewhere because of some very special handling in gf4 environment/ee7 environment.
Comment 6 Sergey Petrov 2013-08-29 06:59:13 UTC
it may have sense to split remaining part of default datasource support into separate issue.
Comment 7 Sergey Petrov 2013-08-30 07:18:05 UTC
2,3 is fixed, 1 may be filed as separate issue/enhancment if consider some custom behaviour like replace empty ds with default etc.