- 阿啵呲嘚
-
Java代码
### The error occurred while setting parameters
### SQL: insert into SYS_SECURITY_RIGHT_SYSTEM( SYSRIGHT_ID, SYS_ORDER, SYS_NAME, SYS_MEMO ) values ( ?, ?, ?, ? )
### Cause: java.sql.SQLException: ORA-01400: 无法将 NULL 插入 ("SMARTCITY"."SYS_SECURITY_RIGHT_SYSTEM"."SYSRIGHT_ID")
]
在使用Mybatis主键自增长时,其要求使用Integer,使用〈selectKey〉时需要数据库中存在一条数据,不然回报上述错误。
Java代码
2013-06-19 09:27:56,109 [http-bio-8080-exec-1] DEBUG [org.mybatis.spring.SqlSessionUtils] - Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1681460]
2013-06-19 09:27:56,119 [http-bio-8080-exec-1] DEBUG [org.mybatis.spring.transaction.SpringManagedTransaction] - JDBC Connection [org.apache.commons.dbcp.PoolableConnection@a1e9b0] will be managed by Spring
2013-06-19 09:27:56,119 [http-bio-8080-exec-1] DEBUG [dci.smartcity.operationsmanagement.dao.IOrgDAO.update] - ooo Using Connection [org.apache.commons.dbcp.PoolableConnection@a1e9b0]
2013-06-19 09:27:56,129 [http-bio-8080-exec-1] DEBUG [dci.smartcity.operationsmanagement.dao.IOrgDAO.update] - ==> Preparing: update SYS_SECURITY_ORG SET ORG_NAME= ?, ORG_PID=?, ORG_ORDER=?, ORG_MEMO=?, ORG_CREATETIME=?, ORG_CREATEUSER=? where ORG_ID = ?
2013-06-19 09:27:56,129 [http-bio-8080-exec-1] DEBUG [dci.smartcity.operationsmanagement.dao.IOrgDAO.update] - ==> Parameters: xx (String), 1(Integer), 2(Integer), dfd (String), 20121111(Integer), ??????? (String), 3(Integer)
2013-06-19 09:27:56,156 [http-bio-8080-exec-1] DEBUG [org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator] - Unable to translate SQLException with Error code "12899", will now try the fallback translator
2013-06-19 09:27:56,159 [http-bio-8080-exec-1] DEBUG [org.springframework.jdbc.support.SQLStateSQLExceptionTranslator] - Extracted SQL state class "72" from value "72000"
2013-06-19 09:27:56,161 [http-bio-8080-exec-1] DEBUG [org.mybatis.spring.SqlSessionUtils] - Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1681460]
在更新时出现如上错误,
错误原因:由于oracle数据库中设置字符串长度为255时,当插入数据aaaaa未满时会以空格填充,在更新时,我们直接在字符串aaaaa后添加时,其位数超过255,在更新时不能成功,并报以上错误。
Exception in thread "main" org.springframework.jdbc.BadSqlGrammarException: SqlMapClient operation; bad SQL grammar []; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in entity/TabB.xml.
--- The error occurred while applying a parameter map.
--- Check the tab_b.insert-InlineParameterMap.
--- Check the statement (update failed).
--- Cause: java.sql.SQLException: ORA-00942: 表或视图不存在
环境:数据库oracle11g,
ibatis的TabB.xml中对应数据库中的表,在运行时不能自动创建,所以只能手动在Oracle中创建表。
Java代码
java.lang.ExceptionInInitializerError
at tools.Test.<clinit>(Test.java:10)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name "sqlSessionFactory" defined in class path resource [applicationContext-all.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: "file [E:eclipsejunoeclipseworkspacessmartcitysmartcity-mybatis argetclassesorgsmartcitydb1entityTabAMapper.xml]"; nested exception is java.lang.RuntimeException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for db1.taba.insert
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1422)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:518)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at tools.ApplicationContextUtils.rebuildApplicationContext(ApplicationContextUtils.java:21)
at tools.ApplicationContextUtils.<clinit>(ApplicationContextUtils.java:12)
... 1 more
Caused by: org.springframework.core.NestedIOException: Failed to parse mapping resource: "file [E:eclipsejunoeclipseworkspacessmartcitysmartcity-mybatis argetclassesorgsmartcitydb1entityTabAMapper.xml]"; nested exception is java.lang.RuntimeException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for db1.taba.insert
at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:462)
at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:336)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1479)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1419)
... 14 more
Caused by: java.lang.RuntimeException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for db1.taba.insert
at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:113)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:88)
at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:460)
... 17 more
Caused by: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for db1.taba.insert
at org.apache.ibatis.session.Configuration$StrictMap.put(Configuration.java:760)
at org.apache.ibatis.session.Configuration$StrictMap.put(Configuration.java:732)
at org.apache.ibatis.session.Configuration.addMappedStatement(Configuration.java:562)
at org.apache.ibatis.builder.MapperBuilderAssistant.addMappedStatement(MapperBuilderAssistant.java:307)
at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:109)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:128)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:121)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:111)
... 19 more