我正在与 JPQL 合作。我有一张表,其中的字段是
1. Name DataType-varchar
2. sub DataType-BIT
在POJO文件中
private String name;
private byte sub;
插入成功为:
姓名=约翰子=0
现在,当我使用以下方法查询该表时:
query = em.createQuery("SELECT c FROM Sample c WHERE c.name = '"+ (name)+ "'", Sample.class);
出现异常:
javax.persistence.PersistenceException: Exception [EclipseLink-3002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.ConversionException
Exception Description: The object [false], of class [class java.lang.Boolean], from mapping [org.eclipse.persistence.mappings.DirectToFieldMapping[sub-->sample.SUB]] with descriptor [RelationalDescriptor(com.org.Test --> [DatabaseTable(sample)])], could not be converted to [class java.lang.Byte].
我认为在获取值时,它在内部会被认为是错误的。我该如何解决这个问题?