Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

通用Mapper 0.2.0: java.lang.AssertionError: Expected exception: org.apache.ibatis.exceptions.PersistenceException #19

Open
pi408637535 opened this issue Mar 7, 2017 · 1 comment

Comments

@pi408637535
Copy link

你好,由于对于通用Mapper我可能看不太懂,所以我决定先来看这个低版本。
我的数据库是Mysql。
配置文件:







public class Country {
@id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String countryname;
private String countrycode;
}

Reader reader = Resources.getResourceAsReader("mybatis-config.xml");
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
reader.close();
//创建数据库
SqlSession session = null;
try {
session = sqlSessionFactory.openSession();
} finally {
if (session != null) {
session.close();
}
}
...
}

country 结构
CREATE TABLE country (
id int(11) unsigned NOT NULL AUTO_INCREMENT,
countryname varchar(32) DEFAULT NULL,
countrycode varchar(2) DEFAULT 'HH',
PRIMARY KEY (id)
) ENGINE=InnoDB AUTO_INCREMENT=188

Mybatis日志:
DEBUG [main] - Setting autocommit to false on JDBC Connection [com.mysql.jdbc.JDBC4Connection@47faa49c]
DEBUG [main] - ==> Preparing: INSERT INTO COUNTRY (ID,COUNTRYNAME,COUNTRYCODE) VALUES ( ?,?,? )
DEBUG [main] - ==> Parameters: null, yyy(String), t(String)
DEBUG [main] - <== Updates: 1
DEBUG [main] - ==> Executing: SELECT LAST_INSERT_ID()
TRACE [main] - <== Columns: LAST_INSERT_ID()
TRACE [main] - <== Row: 190
DEBUG [main] - <== Total: 1
DEBUG [main] - Rolling back JDBC Connection [com.mysql.jdbc.JDBC4Connection@47faa49c]
DEBUG [main] - Resetting autocommit to true on JDBC Connection [com.mysql.jdbc.JDBC4Connection@47faa49c]
DEBUG [main] - Closing JDBC Connection [com.mysql.jdbc.JDBC4Connection@47faa49c]
DEBUG [main] - Returned connection 1207608476 to pool.
Disconnected from the target VM, address: '127.0.0.1:55572', transport: 'socket'

java.lang.AssertionError: Expected exception: org.apache.ibatis.exceptions.PersistenceException

我是真没明白这个错误是怎么发生了,希望能得到答复

@abel533
Copy link
Owner

abel533 commented Mar 7, 2017

看不出来原因

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants