I’m trying to insert a single record to a table using mybatis but encountered java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended
dto:
public class ClientApplications { private Integer clientId; private String appName; private String appAcctName; private String cid; public Integer getClientId() { return clientId; } public void setClientId(Integer clientId) { this.clientId = clientId; } public String getAppName() { return appName; } public void setAppName(String appName) { this.appName = appName; } public String getAppAcctName() { return appAcctName; } public void setAppAcctName(String appAcctName) { this.appAcctName = appAcctName; } public String getCid() { return cid; } public void setCid(String cid) { this.cid = cid; } }
mybatis-mapper.xml:
insert into client_applications (client_id, app_name, app_acct_name, cid, start_date, created_by, eca_created_date, updated_by, updated_date) values (#{clientId}, #{appName}, #{appAcctName}, #{cid}, trunc(sysdate), ‘cltSvc’, sysdate, ‘cltSvc’, sysdate);
mybatis-config.xml:
this is how i’m setting params and calling the insert method :
ClientApplications cltApps = new ClientApplications(1214114, ‘CA’, ‘1231111’, ‘1423423SSD’); mapper.insertClientApplications(cltApps);
org.apache.ibatis.exceptions.PersistenceException:
Error updating database. Cause: java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended
The error may involve com.xyz.insertClientApplications-Inline
The error occurred while setting parameters
SQL: insert into client_applications (client_id, app_name, app_acct_name, cid, start_date, created_by, created_date, updated_by, updated_date) values (?, ?, ?, ?, trunc(sysdate), ‘cltSvc’, sysdate, ‘cltSvc’, sysdate);
Cause: java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:200) at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:185) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.ibatis.session.SqlSessionManager$SqlSessionInterceptor.invoke(SqlSessionManager.java:357) at com.sun.proxy.$Proxy335.insert(Unknown Source) at org.apache.ibatis.session.SqlSessionManager.insert(SqlSessionManager.java:236) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:57) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59) at com.sun.proxy.$Proxy337.insertEntClientApplications(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.mybatis.cdi.SerializableMapperProxy.invoke(SerializableMapperProxy.java:56) at com.sun.proxy.$Proxy337.insertClientApplications(Unknown Source) at com.xyz.AddRelationships.determineAppAcctId(AddRelationships.java:193) at com.xyz.AddRelationships.addRelationships(AddRelationships.java:72) at com.xyz.ProcessAddRelationships.run(ProcessAddRelationships.java:15) at com.xyz.UniqueProcessor.process(UniqueProcessor.java:45) at com.xyz.UniqueProcessor$Proxy$_$$_WeldClientProxy.process(Unknown Source) at com.xyz.Poller.checkEip(Poller.java:97) at com.xyz.Poller.timerTimeout(Poller.java:64) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.oracle.pitchfork.inject.Jsr250Metadata.invokeTimeoutMethodInternal(Jsr250Metadata.java:373) at com.oracle.pitchfork.intercept.LifecycleEventCallbackInvocationContext.proceed(LifecycleEventCallbackInvocationContext.java:126) at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:73) at org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:52) at sun.reflect.GeneratedMethodAccessor179.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.oracle.pitchfork.inject.Jsr250Metadata.invokeLifecycleMethod(Jsr250Metadata.java:388) at com.oracle.pitchfork.intercept.LifecycleEventCallbackInvocationContext.proceed(LifecycleEventCallbackInvocationContext.java:121) at com.oracle.pitchfork.intercept.LifecycleEventCallbackInvocationContext.proceed(LifecycleEventCallbackInvocationContext.java:150) at com.oracle.pitchfork.intercept.InterceptionMetadata.invokeTimeoutMethod(InterceptionMetadata.java:626) at weblogic.ejb.container.injection.EjbComponentCreatorImpl.invokeTimer(EjbComponentCreatorImpl.java:71) at weblogic.ejb.container.injection.InjectionBasedEjbComponentCreator.invokeTimer(InjectionBasedEjbComponentCreator.java:185) at weblogic.ejb.container.manager.BaseEJBManager.invokeTimeoutMethod(BaseEJBManager.java:199) at weblogic.ejb.container.timer.TimerImpl.timerExpired(TimerImpl.java:338) at weblogic.timers.internal.TimerImpl.run(TimerImpl.java:290) at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:666) at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:348) at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:333) at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:54) at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41) at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:640) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:406) at weblogic.work.ExecuteThread.run(ExecuteThread.java:346)
Caused by: java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended
org.apache.ibatis.exceptions.PersistenceException Java Examples
The following examples show how to use org.apache.ibatis.exceptions.PersistenceException . You can vote up the ones you like or vote down the ones you don’t like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: mmpt Author: manniwood File: SmallIntArrayTest.java License: MIT License 6 votes @Test public void testIntegerArrayWithTooLargeValue() { String testName = “too large value test”; boolean exceptionWasCaught = false; IntegerArrayBean t = new IntegerArrayBean(); Integer[] intArray = new Integer[] { 1, Integer.MAX_VALUE, 3 }; t.setIntegerArray(intArray); t.setName(testName); try { session.insert(“test.insertSmallIntArray”, t); } catch (PersistenceException e) { log.info(“caught expected exception: “, e); exceptionWasCaught = true; } finally { session.rollback(true); } Assert.assertTrue(exceptionWasCaught, “Integers larger than PostgreSQL smallint need to throw exeption.”); }
Example #2
Source Project: activiti6-boot2 Author: dingziyang File: ConcurrentEngineUsageTest.java License: Apache License 2.0 6 votes protected void retryStartProcess(String runningUser) { int retries = MAX_RETRIES; int timeout = 200; boolean success = false; while (retries > 0 && !success) { try { runtimeService.startProcessInstanceByKey(“concurrentProcess”, Collections.singletonMap(“assignee”, (Object) runningUser)); success = true; } catch (PersistenceException pe) { retries = retries – 1; log.debug(“Retrying process start – ” + (MAX_RETRIES – retries)); try { Thread.sleep(timeout); } catch (InterruptedException ignore) { } timeout = timeout + 200; } } if (!success) { log.debug(“Retrying process start FAILED ” + MAX_RETRIES + ” times”); } }
Example #3
Source Project: activiti6-boot2 Author: dingziyang File: ConcurrentEngineUsageTest.java License: Apache License 2.0 6 votes protected void retryFinishTask(String taskId) { int retries = MAX_RETRIES; int timeout = 200; boolean success = false; while (retries > 0 && !success) { try { taskService.complete(taskId); success = true; } catch (PersistenceException pe) { retries = retries – 1; log.debug(“Retrying task completion – ” + (MAX_RETRIES – retries)); try { Thread.sleep(timeout); } catch (InterruptedException ignore) { } timeout = timeout + 200; } } if (!success) { log.debug(“Retrying task completion FAILED ” + MAX_RETRIES + ” times”); } }
Example #4
Source Project: activiti6-boot2 Author: dingziyang File: ConcurrentEngineUsageTest.java License: Apache License 2.0 6 votes protected void retryStartProcess(String runningUser) { int retries = MAX_RETRIES; int timeout = 200; boolean success = false; while(retries > 0 && !success) { try { runtimeService.startProcessInstanceByKey(“concurrentProcess”, Collections.singletonMap(“assignee”, (Object)runningUser)); success = true; } catch(PersistenceException pe) { retries = retries – 1; log.debug(“Retrying process start – ” + (MAX_RETRIES – retries)); try { Thread.sleep(timeout); } catch (InterruptedException ignore) { } timeout = timeout + 200; } } if(!success) { log.debug(“Retrying process start FAILED ” + MAX_RETRIES + ” times”); } }
Example #5
Source Project: mybatis Author: tuguangquan File: NestedResultHandlerTest.java License: Apache License 2.0 6 votes @Test(expected=PersistenceException.class) public void testUnorderedGetPersonWithHandler() { SqlSession sqlSession = sqlSessionFactory.openSession(); try { sqlSession.select(“getPersonsWithItemsOrdered”, new ResultHandler() { public void handleResult(ResultContext context) { Person person = (Person) context.getResultObject(); if (“grandma”.equals(person.getName())) { Assert.assertEquals(2, person.getItems().size()); } } }); } finally { sqlSession.close(); } }
Example #6
Source Project: ClosureTableCateogryStore Author: Kaciras File: Main.java License: MIT License 6 votes public static void main(String[] args) throws Exception { Utils.disableIllegalAccessWarning(); if (args.length != 3) { System.err.println(“请设置数据库连接参数,例如:”); System.err.println(“\tjava -jar closure-table.jar jdbc:mariadb://localhost:3306/test root password”); return; } try { session = Utils.createSqlSession(“org.mariadb.jdbc.Driver”, args[0], args[1], args[2]); CategoryMapper mapper = session.getMapper(CategoryMapper.class); repository = new Repository(mapper); Category.categoryMapper = mapper; // 如果使用Spring,可以用@Configurable来注入此依赖。 Utils.executeScript(session.getConnection(), “table.sql”); Runtime.getRuntime().addShutdownHook(new Thread(() -> { Utils.dropTables(session.getConnection()); })); runDemo(); } catch (PersistenceException e) { System.out.println(“错误:无法连接数据库,请检查启动参数。”); } }
Example #7
Source Project: xyTalk-pc Author: xy-Group File: BasicDao.java License: GNU Affero General Public License v3.0 6 votes private BasicModel _findById(String id, int time) { if (time > 10) { System.out.println(“查询到 BasicModel 对象失败次数>10,放弃查询”); return null; } try { return (BasicModel) session.selectOne(className + “.findById”, id); } catch (PersistenceException exception) { System.out.println(“没有查询到 BasicModel 对象,继续查询”); return _findById(id, ++time); } }
Example #8
Source Project: ApplicationPower Author: shalousun File: CustomSqlSessionTemplate.java License: Apache License 2.0 6 votes public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { final SqlSession sqlSession = getSqlSession(CustomSqlSessionTemplate.this.getSqlSessionFactory(), CustomSqlSessionTemplate.this.executorType, CustomSqlSessionTemplate.this.exceptionTranslator); try { Object result = method.invoke(sqlSession, args); if (!isSqlSessionTransactional(sqlSession, CustomSqlSessionTemplate.this.getSqlSessionFactory())) { // force commit even on non-dirty sessions because some databases require // a commit/rollback before calling close() sqlSession.commit(true); } return result; } catch (Throwable t) { Throwable unwrapped = unwrapThrowable(t); if (CustomSqlSessionTemplate.this.exceptionTranslator != null && unwrapped instanceof PersistenceException) { Throwable translated = CustomSqlSessionTemplate.this.exceptionTranslator.translateExceptionIfPossible((PersistenceException) unwrapped); if (translated != null) { unwrapped = translated; } } throw unwrapped; } finally { closeSqlSession(sqlSession, CustomSqlSessionTemplate.this.getSqlSessionFactory()); } }
Example #9
Source Project: taskana Author: Taskana File: AttachmentHandler.java License: Apache License 2.0 6 votes void insertNewAttachmentOnTaskUpdate(TaskImpl newTaskImpl, Attachment attachment) throws AttachmentPersistenceException { LOGGER.debug(“entry to insertNewAttachmentOnTaskUpdate()”); AttachmentImpl attachmentImpl = (AttachmentImpl) attachment; initAttachment(attachmentImpl, newTaskImpl); try { attachmentMapper.insert(attachmentImpl); LOGGER.debug( “TaskService.updateTask() for TaskId={} INSERTED an Attachment={}.”, newTaskImpl.getId(), attachmentImpl); } catch (PersistenceException e) { throw new AttachmentPersistenceException( String.format( “Cannot insert the Attachement %s for Task %s because it already exists.”, attachmentImpl.getId(), newTaskImpl.getId()), e.getCause()); } LOGGER.debug(“exit from insertNewAttachmentOnTaskUpdate(), returning”); }
Example #10
Source Project: multiapps-controller Author: cloudfoundry-incubator File: CFExceptionMapperTest.java License: Apache License 2.0 6 votes public static Stream testHandleException() { return Stream.of( // @formatter:off Arguments.of(new NotFoundException(“Not found”), new RestResponse(404, “Not found”)), Arguments.of(new ConflictException(“Already exists”), new RestResponse(409, “Already exists”)), Arguments.of(new ParsingException(“Bad request”), new RestResponse(400, “Bad request”)), Arguments.of(new ContentException(“Bad request”), new RestResponse(400, “Bad request”)), Arguments.of(new SLException(“SL exception”), new RestResponse(500, “SL exception”)), Arguments.of(new ResponseStatusException(HttpStatus.NOT_FOUND, “Not found”), new RestResponse(404, “Not found”)), Arguments.of(new ResponseStatusException(HttpStatus.BAD_REQUEST, “Bad request”), new RestResponse(400, “Bad request”)), Arguments.of(new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, “Something went wrong”), new RestResponse(500, “Something went wrong”)), Arguments.of(new CloudOperationException(HttpStatus.TOO_MANY_REQUESTS, HttpStatus.TOO_MANY_REQUESTS.getReasonPhrase(), “Rate limit exceeded”), new RestResponse(502, “429 Too Many Requests: Rate limit exceeded”)), Arguments.of(new SQLException(), new RestResponse(500, Messages.TEMPORARY_PROBLEM_WITH_PERSISTENCE_LAYER)), Arguments.of(new PersistenceException(), new RestResponse(500, Messages.TEMPORARY_PROBLEM_WITH_PERSISTENCE_LAYER)) // @formatter:on ); }
Example #11
Source Project: c2mon Author: c2mon File: LoggerDAO.java License: GNU Lesser General Public License v3.0 6 votes @Override public void storeData(IFallback object) throws IDBPersistenceException { SqlSession session = null; try { session = sqlSessionFactory.openSession(); LoggerMapper loggerMapper = session.getMapper(mapperInterface); loggerMapper.insertLog((T) object); session.commit(); } catch (PersistenceException ex1) { String message = “Exception caught while persisting an object to the history”; LOGGER.error(message, ex1); if (session != null) session.rollback(); throw new IDBPersistenceException(message, ex1); } finally { if (session != null) session.close(); } }
Example #12
Source Project: c2mon Author: c2mon File: BatchPersistenceManagerImpl.java License: GNU Lesser General Public License v3.0 6 votes /** * Will not shutdown correctly until all elements can be persisted. */ @Override public synchronized void stop() { LOGGER.info(“Shutting down cache persistence manager (” + cache.getClass().getSimpleName() + “)”); started = false; cachePersistenceThreadPoolTaskExecutor.shutdown(); //may be none-empty if added using addElementToPersist while (!toBePersisted.isEmpty()) { LOGGER.debug(“Detected cache objects that need persisting… trying to persist them.”); toBePersistedLock.writeLock().lock(); try { cachePersistenceDAO.persistBatch(new ArrayList<>(toBePersisted)); toBePersisted.clear(); } catch (PersistenceException e) { LOGGER.error(“Exception caught while persisting final batch of cache objects – will try again in 1s”, e); try { Thread.sleep(1000); } catch (InterruptedException e1) { LOGGER.error(“Interrupted during sleep”, e1); } } finally { toBePersistedLock.writeLock().unlock(); } } }
Example #13
Source Project: flowable-engine Author: flowable File: ConcurrentEngineUsageTest.java License: Apache License 2.0 6 votes protected void retryFinishTask(String taskId) { int retries = MAX_RETRIES; int timeout = 200; boolean success = false; while (retries > 0 && !success) { try { taskService.complete(taskId); success = true; } catch (PersistenceException pe) { retries = retries – 1; LOGGER.debug(“Retrying task completion – {}”, (MAX_RETRIES – retries)); try { Thread.sleep(timeout); } catch (InterruptedException ignore) { } timeout = timeout + 200; } } if (!success) { LOGGER.debug(“Retrying task completion FAILED {} times”, MAX_RETRIES); } }
Example #14
Source Project: flowable-engine Author: flowable File: ConcurrentEngineUsageTest.java License: Apache License 2.0 6 votes protected void retryStartProcess(String runningUser) { int retries = MAX_RETRIES; int timeout = 200; boolean success = false; while (retries > 0 && !success) { try { runtimeService.startProcessInstanceByKey(“concurrentProcess”, Collections.singletonMap(“assignee”, (Object) runningUser)); success = true; } catch (PersistenceException pe) { retries = retries – 1; LOGGER.debug(“Retrying process start – {}”, (MAX_RETRIES – retries)); try { Thread.sleep(timeout); } catch (InterruptedException ignore) { } timeout = timeout + 200; } } if (!success) { LOGGER.debug(“Retrying process start FAILED {} times”, MAX_RETRIES); } }
Example #15
Source Project: flowable-engine Author: flowable File: ConcurrentEngineUsageTest.java License: Apache License 2.0 6 votes protected void retryFinishTask(String taskId) { int retries = MAX_RETRIES; int timeout = 200; boolean success = false; while (retries > 0 && !success) { try { taskService.complete(taskId); success = true; } catch (PersistenceException pe) { retries = retries – 1; LOGGER.debug(“Retrying task completion – {}”, (MAX_RETRIES – retries)); try { Thread.sleep(timeout); } catch (InterruptedException ignore) { } timeout = timeout + 200; } } if (!success) { LOGGER.debug(“Retrying task completion FAILED {} times”, MAX_RETRIES); } }
Example #16
Source Project: flowable-engine Author: flowable File: TenancyTest.java License: Apache License 2.0 6 votes @Test public void testChangeDeploymentIdWithClash() { String processDefinitionIdWithTenant = deployTestProcessWithTestTenant(“tenantA”); deployOneTaskTestProcess(); String deploymentId = this.repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionIdWithTenant).singleResult() .getDeploymentId(); // Changing the one with tenant now back to one without should clash, // cause there already exists one assertThatThrownBy(() -> repositoryService.changeDeploymentTenantId(deploymentId, “”)) .isInstanceOf(PersistenceException.class); // Deploying another version should just up the version String processDefinitionIdNoTenant2 = deployOneTaskTestProcess(); assertThat(repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionIdNoTenant2).singleResult().getVersion()).isEqualTo(2); }
Example #17
Source Project: mybaties Author: shurun19851206 File: NestedResultHandlerTest.java License: Apache License 2.0 6 votes @Test(expected=PersistenceException.class) public void testUnorderedGetPersonWithHandler() { SqlSession sqlSession = sqlSessionFactory.openSession(); try { sqlSession.select(“getPersonsWithItemsOrdered”, new ResultHandler() { public void handleResult(ResultContext context) { Person person = (Person) context.getResultObject(); if (“grandma”.equals(person.getName())) { Assert.assertEquals(2, person.getItems().size()); } } }); } finally { sqlSession.close(); } }
Example #18
Source Project: mybaties Author: shurun19851206 File: UnknownObjectTest.java License: Apache License 2.0 6 votes @Test(expected=PersistenceException.class) public void shouldFailBecauseThereIsAPropertyWithoutTypeHandler() throws Exception { // create a SqlSessionFactory Reader reader = Resources.getResourceAsReader(“org/apache/ibatis/submitted/unknownobject/mybatis-config.xml”); sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader); reader.close(); // populate in-memory database SqlSession session = sqlSessionFactory.openSession(); Connection conn = session.getConnection(); reader = Resources.getResourceAsReader(“org/apache/ibatis/submitted/unknownobject/CreateDB.sql”); ScriptRunner runner = new ScriptRunner(conn); runner.setLogWriter(null); runner.runScript(reader); reader.close(); session.close(); }
Example #19
Source Project: mybatis Author: tuguangquan File: SqlSessionManagerTest.java License: Apache License 2.0 5 votes @Test public void shouldThrowExceptionIfMappedStatementDoesNotExistAndSqlSessionIsOpen() throws Exception { try { manager.startManagedSession(); manager.selectList(“ThisStatementDoesNotExist”); fail(“Expected exception to be thrown due to statement that does not exist.”); } catch (PersistenceException e) { assertTrue(e.getMessage().contains(“does not contain value for ThisStatementDoesNotExist”)); } finally { manager.close(); } }
Example #20
Source Project: ClosureTableCateogryStore Author: Kaciras File: Repository.java License: MIT License 5 votes /** * 该方法仅更新分类的属性,不修改继承关系,若要移动节点请使用 * Category.moveTo()
和Category.moveTreeTo()
* * @param category 新的分类信息对象 */ public void update(Category category) { try { Utils.checkEffective(categoryMapper.update(category)); } catch (PersistenceException ex) { throw new IllegalArgumentException(ex); } }
Example #21
Source Project: tk-mybatis Author: godlike110 File: TestInsertSelective.java License: MIT License 5 votes /** * 插入空数据,id不能为null,会报错 */ @Test(expected = PersistenceException.class) public void testDynamicInsertAll() { SqlSession sqlSession = MybatisHelper.getSqlSession(); try { CountryMapper mapper = sqlSession.getMapper(CountryMapper.class); mapper.insertSelective(new Country()); } finally { sqlSession.close(); } }
Example #22
Source Project: mybatis Author: tuguangquan File: EmptyNamespaceTest.java License: Apache License 2.0 5 votes @Test(expected = PersistenceException.class) public void testEmptyNamespace() throws Exception { Reader reader = Resources.getResourceAsReader(“org/apache/ibatis/submitted/empty_namespace/ibatisConfig.xml”); try { new SqlSessionFactoryBuilder().build(reader); } finally { reader.close(); } }
Example #23
Source Project: tk-mybatis Author: godlike110 File: TestInsert.java License: MIT License 5 votes /** * 插入空数据,id不能为null,会报错 */ @Test(expected = PersistenceException.class) public void testDynamicInsertAll() { SqlSession sqlSession = MybatisHelper.getSqlSession(); try { CountryMapper mapper = sqlSession.getMapper(CountryMapper.class); mapper.insert(new Country()); } finally { sqlSession.close(); } }
Example #24
Source Project: tk-mybatis Author: godlike110 File: TestInsert.java License: MIT License 5 votes /** * 不能插入null */ @Test(expected = PersistenceException.class) public void testDynamicInsertAllByNull() { SqlSession sqlSession = MybatisHelper.getSqlSession(); try { CountryMapper mapper = sqlSession.getMapper(CountryMapper.class); mapper.insert(null); } finally { sqlSession.close(); } }
Example #25
Source Project: taskana Author: Taskana File: WorkbasketQueryImpl.java License: Apache License 2.0 5 votes @Override public List list(int offset, int limit) { LOGGER.debug(“entry to list(offset = {}, limit = {}), this = {}”, offset, limit, this); List workbaskets = new ArrayList<>(); try { taskanaEngine.openConnection(); RowBounds rowBounds = new RowBounds(offset, limit); handleCallerRolesAndAccessIds(); workbaskets = taskanaEngine.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds); return workbaskets; } catch (PersistenceException e) { if (e.getMessage().contains(“ERRORCODE=-4470”)) { TaskanaRuntimeException ex = new TaskanaRuntimeException( “The offset beginning was set over the amount of result-rows.”, e.getCause()); ex.setStackTrace(e.getStackTrace()); throw ex; } throw e; } finally { taskanaEngine.returnConnection(); if (LOGGER.isDebugEnabled()) { LOGGER.debug( “exit from list(offset,limit). Returning {} resulting Objects: {} “, workbaskets.size(), workbaskets); } } }
Example #26
Source Project: taskana Author: Taskana File: AbstractWorkbasketAccessItemQueryImpl.java License: Apache License 2.0 5 votes @Override public List list(int offset, int limit) { LOGGER.debug(“entry to list(offset = {}, limit = {}), this = {}”, offset, limit, _this()); List result = new ArrayList<>(); try { taskanaEngine.openConnection(); RowBounds rowBounds = new RowBounds(offset, limit); List foundAccessItms = taskanaEngine.getSqlSession().selectList(getLinkToMapper(), _this(), rowBounds); result.addAll(foundAccessItms); return result; } catch (PersistenceException e) { if (e.getMessage().contains(“ERRORCODE=-4470”)) { TaskanaRuntimeException ex = new TaskanaRuntimeException( “The offset beginning was set over the amount of result-rows.”, e.getCause()); ex.setStackTrace(e.getStackTrace()); throw ex; } throw e; } finally { taskanaEngine.returnConnection(); if (LOGGER.isDebugEnabled()) { LOGGER.debug( “exit from list(offset,limit). Returning {} resulting Objects: {} “, result.size(), result); } } }
Example #27
Source Project: taskana Author: Taskana File: WorkbasketAccessItemQueryImpl.java License: Apache License 2.0 5 votes @Override public List list(int offset, int limit) { LOGGER.debug(“entry to list(offset = {}, limit = {}), this = {}”, offset, limit, this); List result = new ArrayList<>(); try { taskanaEngine.openConnection(); RowBounds rowBounds = new RowBounds(offset, limit); List foundAccessItms = taskanaEngine.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds); result.addAll(foundAccessItms); return result; } catch (PersistenceException e) { if (e.getMessage().contains(“ERRORCODE=-4470”)) { TaskanaRuntimeException ex = new TaskanaRuntimeException( “The offset beginning was set over the amount of result-rows.”, e.getCause()); ex.setStackTrace(e.getStackTrace()); throw ex; } throw e; } finally { taskanaEngine.returnConnection(); if (LOGGER.isDebugEnabled()) { LOGGER.debug( “exit from list(offset,limit). Returning {} resulting Objects: {} “, result.size(), result); } } }
Example #28
Source Project: taskana Author: Taskana File: ClassificationQueryImpl.java License: Apache License 2.0 5 votes @Override public List list(int offset, int limit) { LOGGER.debug(“entry to list(offset = {}, limit = {}), this = {}”, offset, limit, this); List result = new ArrayList<>(); try { taskanaEngine.openConnection(); RowBounds rowBounds = new RowBounds(offset, limit); result = taskanaEngine.getSqlSession().selectList(LINK_TO_SUMMARYMAPPER, this, rowBounds); return result; } catch (Exception e) { if (e instanceof PersistenceException) { if (e.getMessage().contains(“ERRORCODE=-4470”)) { TaskanaRuntimeException ex = new TaskanaRuntimeException( “The offset beginning was set over the amount of result-rows.”, e.getCause()); ex.setStackTrace(e.getStackTrace()); throw ex; } } throw e; } finally { taskanaEngine.returnConnection(); if (LOGGER.isDebugEnabled()) { LOGGER.debug( “exit from list(offset,limit). Returning {} resulting Objects: {} “, result.size(), result); } } }
Example #29
Source Project: mybatis Author: tuguangquan File: SelectKeyTest.java License: Apache License 2.0 5 votes @Test(expected=PersistenceException.class) public void testSeleckKeyReturnsTooManyData() { SqlSession sqlSession = sqlSessionFactory.openSession(); try { Map parms = new HashMap(); parms.put(“name”, “Fred”); sqlSession.insert(“org.apache.ibatis.submitted.selectkey.Table2.insertTooManyValuesInSelectKey”, parms); sqlSession.insert(“org.apache.ibatis.submitted.selectkey.Table2.insertTooManyValuesInSelectKey”, parms); } finally { sqlSession.close(); } }
Example #30