We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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我可能看不太懂,所以我决定先来看这个低版本。 我的数据库是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
country
id
countryname
countrycode
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
我是真没明白这个错误是怎么发生了,希望能得到答复
The text was updated successfully, but these errors were encountered:
看不出来原因
Sorry, something went wrong.
No branches or pull requests
你好,由于对于通用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
我是真没明白这个错误是怎么发生了,希望能得到答复
The text was updated successfully, but these errors were encountered: