[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] @Convert, Custom Mapping Problem
|
This issue is you are setting the converters as SessionCustomizers in your
persistence.xml. Do not do this. The annotations are all that you need.
>> <property name="eclipselink.session.customizer"
>> value="jpa.ConverterOMSDatum"/>
>> <property name="eclipselink.session.customizer"
>> value="jpa.ConverterBoolean"/>
Dr. M.Olbrich wrote:
>
> Hi,
>
> switching from Oracle Toplink to EclipseLink 1.0.1
> i get an Exception in eclipseLink when using a Converter
> which should map from Boolean to String (YES, NO). In Toplink (older)
> it works fine.
> Here is my Entity Class, persistence.xml and the exception stacktrace.
>
> ##############################################################################
> @Entity
> @Table(name = "PERSON", schema = "SYNCRO")
> @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
> @Converter(name="ConverterBoolean",
> converterClass=jpa.ConverterBoolean.class)
> abstract public class Person extends OMSBean implements
> java.io.Serializable {
> ...
> @Column(name = "adult", nullable = false, length = 80)
> @Convert("ConverterBoolean")
> protected boolean adult;
> public boolean isAdult() { return adult;}
> public void setAdult(boolean adult) {
> PropertyChangeEvent pce = new PropertyChangeEvent(this, "adult",
> this.adult, adult);
> this.adult = adult;
> this.firePropertyChange(pce);
> }
> ...
> ...
> ##############################################################################
> Persistence.xml:
> <persistence-unit name ="pu-oracle">
> <description>Basic javaSE application containing JSR 220
> entity beans</description>
>
> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
>
> <class>model.Person</class>
> <properties>
> <!-- JDBC connection properties -->
> <property name="eclipselink.jdbc.driver"
> value="oracle.jdbc.driver.OracleDriver"/>
> <property name="eclipselink.jdbc.url"
> value="jdbc:oracle:thin:@localhost:1521:xe"/>
>
> <!-- Customized Property Mappings -->
> <property
> name="eclipselink.session.customizer" value="jpa.ConverterOMSDatum"/>
> <property
> name="eclipselink.session.customizer" value="jpa.ConverterBoolean"/>
> ...
> ##############################################################################
>
> [EL Warning]: 2008.11.04 14:32:05.165--ServerSession(14694596)--Ignoring
> default serialization on element [protected boolean model.Person.adult]
> within entity class [class model.Person] since a @Convert is specified.
> 8375 [AWT-EventQueue-0] ERROR view.MainFrame - Exception
> [EclipseLink-28014] (Eclipse Persistence Services - 1.0.1 (Build
> 20080905)): org.eclipse.persistence.exceptions.EntityManagerSetupException
> Exception Description: Exception was thrown while processing property
> [eclipselink.session.customizer] with value [jpa.ConverterBoolean].
> Internal Exception: java.lang.ClassCastException: jpa.ConverterBoolean
> cannot be cast to org.eclipse.persistence.config.SessionCustomizer
> Local Exception Stack:
>
>
> Exception [EclipseLink-28014] (Eclipse Persistence Services - 1.0.1 (Build
> 20080905)): org.eclipse.persistence.exceptions.EntityManagerSetupException
> Exception Description: Exception was thrown while processing property
> [eclipselink.session.customizer] with value [jpa.ConverterBoolean].
> Internal Exception: java.lang.ClassCastException: jpa.ConverterBoolean
> cannot be cast to org.eclipse.persistence.config.SessionCustomizer
> at
> org.eclipse.persistence.exceptions.EntityManagerSetupException.failedWhileProcessingProperty(EntityManagerSetupException.java:178)
> at
> org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.processSessionCustomizer(EntityManagerSetupImpl.java:1222)
> at
> org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.updateServerSession(EntityManagerSetupImpl.java:1198)
> at
> org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:237)
> at
> org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:69)
> at
> org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:118)
> at
> org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:112)
> at
> org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:100)
> at view.Syncro_absatzApp.startup(Syncro_absatzApp.java:117)
> at org.jdesktop.application.Application$1.run(Application.java:171)
> at
> java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
> at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
> at
> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
> at
> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
> at
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
> at
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
> at
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
> at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
> Caused by: java.lang.ClassCastException: jpa.ConverterBoolean cannot be
> cast to org.eclipse.persistence.config.SessionCustomizer
> at
> org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.processSessionCustomizer(EntityManagerSetupImpl.java:1219)
> ... 16 more
> ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code =
> -2
> JDWP exit error AGENT_ERROR_NO_JNI_ENV(183): [../
>
>
-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
http://www.eclipse.org/eclipselink/
EclipseLink , http://www.oracle.com/technology/products/ias/toplink/
TopLink
Wiki: http://wiki.eclipse.org/EclipseLink EclipseLink ,
http://wiki.oracle.com/page/TopLink TopLink
Forums: http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
http://www.nabble.com/EclipseLink-f26430.html EclipseLink
Book: http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
--
View this message in context: http://www.nabble.com/%40Convert%2C-Custom-Mapping-Problem-tp20322669p20323017.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.