我曾经 AliasToBeanResultTransformer
在hibernate中执行以下查询
sql查询1
//Query 1
final String GET_ASSIGNMENT_STATUS =
"select distinct wtd.work_task_detail_id as workTaskDetailId, wtd.assigned_task as assignedTask, "
+ "e.emp_id as employeeId, concat( e.first_name,' ',e.last_name ) as employeeName, "
+ "wtd.deadline_date as deadlineDate, a.code_name as workTaskStatusName, a.code_id as workTaskStatusId, "
+ "wtd.completion_date as completionDate, wtd.priority as priority "
+ "from work_task_detail wtd "
+ "join allcode a on a.code_id = wtd.work_task_status "
+ "join employee e on e.emp_id = wtd.team_member_id "
+ "where wtd.work_task_detail_id = :assignmentId";
如果我在mysql union query中使用了相同的选择条件,它会给我异常illegalargumentexception:参数类型不匹配
sql查询2
//Query 2
final String GET_ASSIGNMENT_STATUS =
"select distinct wtd.work_task_detail_id as workTaskDetailId, wtd.assigned_task as assignedTask, "
+ "e.emp_id as employeeId, concat( e.first_name,' ',e.last_name ) as employeeName, "
+ "wtd.deadline_date as deadlineDate, a.code_name as workTaskStatusName, a.code_id as workTaskStatusId, "
+ "wtd.completion_date as completionDate, wtd.priority as priority "
+ "from work_task_detail wtd "
+ "join logs l on wtd.work_task_detail_id = l.tran_id and l.transaction='ASGNMT' "
+ "join user u on u.user_id = l.user_id "
+ "join employee e on e.emp_id = u.emp_id "
+ "join allcode a on a.code_id = wtd.work_task_status "
+ "where wtd.work_task_detail_id = :assignmentId and l.user_id = :userId "
+ "union "
+ "select distinct wtd.work_task_detail_id as workTaskDetailId, wtd.assigned_task as assignedTask, "
+ "e.emp_id as employeeId, concat( e.first_name,' ',e.last_name ) as employeeName, "
+ "wtd.deadline_date as deadlineDate, a.code_name as workTaskStatusName, a.code_id as workTaskStatusId, "
+ "wtd.completion_date as completionDate, wtd.priority as priority "
+ "from work_task_detail wtd "
+ "join allcode a on a.code_id = wtd.work_task_status "
+ "join employee e on e.emp_id = wtd.team_member_id "
+ "where wtd.work_task_detail_id = :assignmentId and wtd.team_member_id = ( select emp_id from user uu where uu.user_id = :userId )";
为什么使用并集会导致以下异常?
日志
05-01-2018 12:14:57 320 org.hibernate.property.access.spi.SetterMethodImpl.set(SetterMethodImpl.java:97)
HHH000123: IllegalArgumentException in class: support.dto.AssignmentStatus, setter method of property: priority
05-01-2018 12:14:57 324 org.hibernate.property.access.spi.SetterMethodImpl.set(SetterMethodImpl.java:98)
HHH000091: Expected type: boolean, actual value: java.lang.Byte
另一个
05-01-2018 12:14:57 342 support.DAO.ImplDeveloperDAO.getAssignmentStatus(ImplDeveloperDAO.java:1916)
Message :- IllegalArgumentException occurred while calling setter for property [support.dto.AssignmentStatus.priority (expected type = boolean)]; target = [support.dto.AssignmentStatus@11643c8], property value = [0] setter of support.dto.AssignmentStatus.priority
05-01-2018 12:14:57 345 support.DAO.ImplDeveloperDAO.getAssignmentStatus(ImplDeveloperDAO.java:1917)
Root Cause :- java.lang.IllegalArgumentException: argument type mismatch
05-01-2018 12:14:57 346 support.DAO.ImplDeveloperDAO.getAssignmentStatus(ImplDeveloperDAO.java:1918)
************************************************************
到目前为止我试过的
我在选择标准中使用了if(wtd.priority=0,false,true)
我还试了两个超负荷设置器 priority
一个参数为 byte
其他的有 BigInteger
1条答案
按热度按时间vyu0f0g11#
我提到这个答案仍然有问题,并提出建议
Expected type: boolean, actual value: java.lang.String
所以我重载了字段的setter方法priority
接受String
作为论据。现在一切如期而至。谢谢您。