我有一个类(称为 A 类),它包含作为属性的子类(称为 B 类)。
所以
public class Request {
private User user;
private ZonedDateTime requestTime;
//getters,setters
}
public class User {
private Integer userID;
//getters,setters
我想要做的是插入请求,或者在代码中(假设 myUser 和 loggerMapper 已经创建):
Request myRequest = new Request();
myRequest.setuser(myUser);
ZonedDateTime z = ZonedDateTime.now();
myRequest.setrequestTime(z);
loggerMapper.logRequest(myRequest);
我有一个界面:
public interface loggerMapper {
Boolean logRequest(Request myRequest);
}
还有一个像这样的 xml 映射器:
<insert id="logRequest" parameterType="map">
insert into Request(userID,requestTime)
values (#{userID},#{requestTime})
</insert>
myBatis absolutley 讨厌 ZonedDateTime,它只是在抱怨
java.lang.IllegalStateException: Type handler was null on parameter mapping for property 'requestTime'.