如题。
package org.yang.beans;
import java.io.Serializable;
import java.util.Date;
public class Article implements Serializable
{
private static final long serialVersionUID = 1L;
private Integer id;
private String typeClass;
private String content;
private Date publicedDate = new Date();
private String author = "杨志永";
private String title;
public Integer getId()
{
return id;
}
public void setId(Integer id)
{
this.id = id;
}
public Date getPublicedDate()
{
return publicedDate;
}
public void setPublicedDate(Date publicedDate)
{
this.publicedDate = publicedDate;
}
public String getTypeClass()
{
return typeClass;
}
public void setTypeClass(String typeClass)
{
this.typeClass = typeClass;
}
public String getContent()
{
return content;
}
public void setContent(String content)
{
this.content = content;
}
public String getAuthor()
{
return author;
}
public void setAuthor(String author)
{
this.author = author;
}
public String getTitle()
{
return title;
}
public void setTitle(String title)
{
this.title = title;
}
}
想要在mybatis中插入这个对象,我这样做无效:
package org.yang.dao;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.yang.beans.Article;
public interface ArticleMapper
{
@Insert("INSERT INTO articles (typeClass, content, publicedDate, author, title) VALUES (#{typeClass}, #{content}, #{publicedDate}, #{author}, #{title})")
@Options(useGeneratedKeys = true, keyProperty = "id")
int addNewArticle(Article article);
}
调用 Action:
int result = service.addNewArticle( this.getArticle() );
然后提示错误:
org.apache.ibatis.exceptions.PersistenceException: ### Error updating database. Cause: java.sql.SQLException: Incorrect string value: '\xE9\x9F\xB3\xE4\xB9\x90' for column 'typeClass' at row 1
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。