Bug 392702 - [JPA 2.1] Spec based Converter support (tolerance)
Summary: [JPA 2.1] Spec based Converter support (tolerance)
Status: RESOLVED FIXED
Alias: None
Product: Dali JPA Tools
Classification: WebTools
Component: JPA (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows 7
: P2 enhancement (vote)
Target Milestone: 3.3 M6   Edit
Assignee: Karen Butzke CLA
QA Contact:
URL:
Whiteboard: JPA2.1
Keywords: plan
Depends on:
Blocks:
 
Reported: 2012-10-23 17:30 EDT by Neil Hauge CLA
Modified: 2013-08-06 16:08 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Neil Hauge CLA 2012-10-23 17:30:33 EDT
The JPA 2.1 spec has added the concept of Converters in the form of @Converter and @Convert(s) in annotation form, with corresponding XML mapping file configuration.

We will need to integrate this support into our existing notion of Converters already in use in the EclipseLink platform.  Support should include UI, validation (namespace investigation needed), and content assist in both Java and XML mapping file.
Comment 1 Karen Butzke CLA 2013-02-19 12:33:37 EST
For M6, tolerance of Converters listed in the persistence.xml and orm.xml has been added. This prevents us from getting invalid validation for classes annotated with @Converter. The remaining work for UI and new validation is spec'd out in bug 401218.
Comment 2 Karen Butzke CLA 2013-02-19 15:19:43 EST
Functional changes:

- persistence.xml supports having a class listed that has an @javax.persistence.Converter on it. Before there was an incorrect validation error that the class was listed but not mapped. Now a class that is listed in the persistence.xml but that does not have @Entity, @MappedSuperclass, @Embeddable, or @Converter will have the error: "Class "Foo" is listed in the persistence.xml file, but is not annotated". A class with one of those annotations that is not listed in the persistence.xml will have the error:" Class "Foo" is managed, but is not listed in the persistence.xml file"

- 'Synchronize classes' action will find classes annotated with @javax.persistence.Converter and not listed in a mapping file (pre-2.1 it only finds @Entity, @Embeddable, and @MappedSuperclass)

- added code-assist for converter-class in orm.xml 
<converter class="model.FooConverter"></converter>

- in eclipselink-orm.xml a converter element at the entity-mappings level is an EclipseLink converter if it has a "name" attribute. Otherwise it is considered a JPA 2.1 converter. An EclipseLink converter can be referenced via name by the EclipseLink @Convert annotation or convert element <convert>fooConverter</convert>. As an EclipseLink converter it is part of the converter namespace and we have validation for ensuring 2 converters don't have the same name.  A JPA 2.1 converter would be referenced via the javax.persistence.Convert or the convert element converter attribute <convert converter="model.FooConverter"/>.

- Project Explorer JPA Content will show converters listed either in the persistence.xml or in an orm.xml. The JPA Structure view will only show converters for a persistence.xml file. The JPA Details view will not display anything for a converter.
Comment 3 Missing name CLA 2013-08-05 04:41:39 EDT
(In reply to comment #2)
> Functional changes:
> 
> - persistence.xml supports having a class listed that has an
> @javax.persistence.Converter on it. Before there was an incorrect validation
> error that the class was listed but not mapped. Now a class that is listed
> in the persistence.xml but that does not have @Entity, @MappedSuperclass,
> @Embeddable, or @Converter will have the error: "Class "Foo" is listed in
> the persistence.xml file, but is not annotated". A class with one of those
> annotations that is not listed in the persistence.xml will have the error:"
> Class "Foo" is managed, but is not listed in the persistence.xml file"
> 
> - 'Synchronize classes' action will find classes annotated with
> @javax.persistence.Converter and not listed in a mapping file (pre-2.1 it
> only finds @Entity, @Embeddable, and @MappedSuperclass)
> 
> - added code-assist for converter-class in orm.xml 
> <converter class="model.FooConverter"></converter>
> 
> - in eclipselink-orm.xml a converter element at the entity-mappings level is
> an EclipseLink converter if it has a "name" attribute. Otherwise it is
> considered a JPA 2.1 converter. An EclipseLink converter can be referenced
> via name by the EclipseLink @Convert annotation or convert element
> <convert>fooConverter</convert>. As an EclipseLink converter it is part of
> the converter namespace and we have validation for ensuring 2 converters
> don't have the same name.  A JPA 2.1 converter would be referenced via the
> javax.persistence.Convert or the convert element converter attribute
> <convert converter="model.FooConverter"/>.
> 
> - Project Explorer JPA Content will show converters listed either in the
> persistence.xml or in an orm.xml. The JPA Structure view will only show
> converters for a persistence.xml file. The JPA Details view will not display
> anything for a converter.

Dear Karen,

I just installed Eclipse Kepler 32-Bit, added JBoss-Tool for Kepler, created a new web project with a maven archetype. So then, I added an entity bean - only using annotation @Entity and @GeneratedValue for the ID. No converter.

I don't want to register my entity beans in persistence.xml or any JPA implementation specific xml file. Using @Entity, I thought that is fine. Why does Kepler/Dali display the following  error: Class "Foo" is managed, but is not listed in the persistence.xml file? This error does NOT occur in Eclipse Juno.

Did you receive any responses from other users?

Thanky you.
Comment 4 Neil Hauge CLA 2013-08-06 16:08:18 EDT
Check you JPA project properties and be sure to select "Discover annotated classes automatically" in the "Persistent class management" section.  Doing this should provide the correct validation for your use case.