Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] problem/misunderstanding with converters

Did you try?
      @ConversionValue(dataValue="N", objectValue="false"),
      @ConversionValue(dataValue="Y", objectValue="true")}

Cheers,
Guy


On 26/10/2011 9:24 AM, Geronimo Ma. Hernandez wrote:
Hello,

I have some trouble using converter annotations with eclipselink 2.3

Using @TypeConverter for Date types, where I want to store the timecode, works 
pretty well.

Trying somewhat similar with Boolean attributes does not work at all. I tried 
both @TypeConverter and @ObjectTypeConverter
The former is silently ignored and the values are stored as tinyInt, the 
latter results in an exception.

If I read entries from bugzilla right, the problems should be fixed, so may be 
I did something wrong with annotations ...

Any help is appreciated!

kind regards

Gero


Local Exception Stack: 
Exception [EclipseLink-3002] (Eclipse Persistence Services - 2.3.1.v20110908-
r10021): org.eclipse.persistence.exceptions.ConversionException
Exception Description: The object [Y], of class [class java.lang.String], from 
mapping [org.eclipse.persistence.mappings.DirectToFieldMapping[loginAllowed--
Tenant.loginAllowed]] with descriptor [RelationalDescriptor(...Tenant --> 
[DatabaseTable(Tenant)])], could not be converted to [class 
java.lang.Boolean].
	at 
org.eclipse.persistence.exceptions.ConversionException.couldNotBeConverted(ConversionException.java:71)
	at 
org.eclipse.persistence.internal.helper.ConversionManager.convertObjectToBoolean(ConversionManager.java:271)
	at 
org.eclipse.persistence.internal.helper.ConversionManager.convertObject(ConversionManager.java:131)
	at 
org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform.convertObject(DatasourcePlatform.java:160)
	at 
org.eclipse.persistence.mappings.foundation.AbstractDirectMapping.getFieldValue(AbstractDirectMapping.java:840)
	at 
org.eclipse.persistence.internal.expressions.QueryKeyExpression.getFieldValue(QueryKeyExpression.java:372)
	at 
org.eclipse.persistence.internal.expressions.ConstantExpression.printSQL(ConstantExpression.java:150)
	at 
org.eclipse.persistence.expressions.ExpressionOperator.printDuo(ExpressionOperator.java:2016)
	at 
org.eclipse.persistence.internal.expressions.CompoundExpression.printSQL(CompoundExpression.java:277)
	at 
org.eclipse.persistence.internal.expressions.RelationExpression.printSQL(RelationExpression.java:708)
	at 
org.eclipse.persistence.internal.expressions.ExpressionSQLPrinter.translateExpression(ExpressionSQLPrinter.java:306)
	at 
org.eclipse.persistence.internal.expressions.ExpressionSQLPrinter.printExpression(ExpressionSQLPrinter.java:129)
	at 
org.eclipse.persistence.internal.expressions.SQLSelectStatement.printSQL(SQLSelectStatement.java:1442)
	at 
org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.printSQLSelectStatement(DatabasePlatform.java:2980)
	at 
org.eclipse.persistence.platform.database.MySQLPlatform.printSQLSelectStatement(MySQLPlatform.java:638)
	at 
org.eclipse.persistence.internal.expressions.SQLSelectStatement.buildCall(SQLSelectStatement.java:752)
	at 
org.eclipse.persistence.internal.expressions.SQLSelectStatement.buildCall(SQLSelectStatement.java:762)
	at 
org.eclipse.persistence.descriptors.ClassDescriptor.buildCallFromStatement(ClassDescriptor.java:755)




excerpt from entity definition:
-------------------------------
@ObjectTypeConverter (
   name="logicalConverter",
   dataType=java.lang.String.class,
   objectType=java.lang.Boolean.class,
   conversionValues={
      @ConversionValue(dataValue="N", objectValue="FALSE"),
      @ConversionValue(dataValue="Y", objectValue="TRUE")}
)
@Column(name = "loginAllowed", columnDefinition="CHAR(1) not null default 'N'")
private Boolean loginAllowed;
                                                                                 
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Back to the top