您好我通过AMF连接实现了一些测试,以测试性能 部署到wildfly8应用程序服务器实例的服务,用于保存复杂类型的实体。 该实体包含如下字段:
private Quantity<Float> quantity = null;
当数量是对象时。
public class Quantity<T extends Number> implements Serializable
当对此字段进行估值时,会引发异常:
javax.ejb.EJBTransactionRolledbackException: java.lang.Double cannot be cast to java.lang.Float
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:163)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:253)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:342)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
Caused by: java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Float
at org.hibernate.type.descriptor.java.FloatTypeDescriptor.unwrap(FloatTypeDescriptor.java:36)
at org.hibernate.type.descriptor.sql.RealTypeDescriptor$1.doBind(RealTypeDescriptor.java:64)
at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:90)
at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:286)
at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:281)
at org.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:367)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2843)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3121)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3581)`
正如此链接(http://flexblog.faratasystems.com/index.php/custom-type-masrhaller-in-blazeds)所示,我尝试使用NumberDecoder覆盖方法ASTranslator.convert(Object source,Class desiredClass)来解决BlazeDS中已知的问题,但没有任何改变。
问题是Flex java包装类(即Float,Double,Long,Integer,Short,Byte,BigDecimal和BigInteger)和简单类型(即float,double,long,int,short,byte)被编组到AS3中数字类型。