spring-mybatis

MyBatis full annotation config to retrieve stored procedure result in OUT parameter?

喜你入骨 提交于 2019-12-12 19:25:11
问题 We have an Oracle stored procedure that returns its results in a SYS_REFCURSOR type OUT parameter. We would like to call this through a MyBatis mapper, the relevant part of the query string in the @Select annotation looks as follows @Select(value="call " + SCHEMA_NAME + "." + STORED_PROCEDURE_NAME + "(" + ... "#{" + P_RECORDSET_FIELD + ",javaType=java.sql.ResultSet,jdbcType=CURSOR,mode=OUT,resultMap=ownNameSpace.ownResultMap}," + ... where the resultMap property refers to the following XML

MyBatis with Guava multimap

萝らか妹 提交于 2019-12-12 09:04:56
问题 I want to use Guava multimap as a resultMap with MyBatis, to return a resultset that has a collection of several one to many entries, but I am not able to figure out the exact syntax for the same. Below is a sample of my table : +----+---------+----------+-------------+ | ID | PART_ID | NAME | PART_FAMILY | +----+---------+----------+-------------+ | 1 | 1 | bush | 300 | | 2 | 1 | a-bush | 300 | | 3 | 1 | 300-bush | 300 | | 4 | 2 | nut | 301 | +----+---------+----------+-------------+ I want

Spring step does not run properly when I “fib” the reader, must I use a tasklet?

自闭症网瘾萝莉.ら 提交于 2019-12-11 14:09:54
问题 I'm aware that all spring steps need to have a reader, a writer, and optionally a processor. So even though my step only needs a writer, I am also fibbing a reader that does nothing but make spring happy. This is based on the solution found here. Is it outdated, or am I missing something? I have a spring batch job that has two chunked steps. My first step, deleteCount , is just deleting all rows from the table so that the second step has a clean slate. This means my first step doesn't need a

How to integrate Spring Boot, Camel and Mybatis

青春壹個敷衍的年華 提交于 2019-12-11 13:08:20
问题 Need to Integrate Camel and MyBatis with application using SpringBoot. SpringBoot provides out-of-box support for Camel and MyBatis. Also provides Camel and MyBatis SpringBoot starters. However, when i try to integrate Spring Boot application with Camel and MyBatis, it fails. I am using Java DSL based Camel Route. Also using Mybatis Spring boot dependencies. Annotate mappers, added database properties in the application.properties file. What I was expecting to happen: 1) SpringBoot setup

Configure c3p0 in spring application context (intSQL and timezone)

核能气质少年 提交于 2019-12-11 02:05:00
问题 How to configure c3p0 in spring application context? I am running mybatis + spring + c3p0 + Oracle 11g. c3p0 documentation for extensions says: extensions Default: an empty java.util.Map A java.util.Map (raw type) containing the values of any user-defined configuration extensions defined for this DataSource. c3p0 documentation for user extensions to configurations says: <extensions> <property name="initSql">SET SCHEMA 'foo'</property> <property name="timezone">PDT</property> </extensions>

MyBatis Spring Boot custom type handler

我的未来我决定 提交于 2019-12-10 21:55:25
问题 I need help with Spring Boot and MyBatis integration. I have an issue with custom BaseTypeHandler. I've created a mapper: @MappedTypes({LocalDateTime.class}) public class LocalDateTimeHandler extends BaseTypeHandler<LocalDateTime> { I've added a type handler: sqlSessionFactory.setTypeHandlers(new LocalDateTimeHandler[]{new LocalDateTimeHandler()}); And I have next error: org.apache.ibatis.executor.ExecutorException: No constructor found in com.some.space.SomeObject matching [java.lang.Integer

Spring Service @Transactional doesn't rollback transaction Mybatis SqlSession

血红的双手。 提交于 2019-12-10 12:47:06
问题 The goal is to rollback all/any transactions in case of failure. But this doesn't work as expected. We use Spring MVC + JMS + Service + Mybatis. In the logs, the JMS is set to rollback, but the row is inserted and not rollback. Would like to know what I'm missing or doing wrong? The @Transactional tag was added recently. So not sure if it works as expected. Code: Service Class: @Transactional(value = "transactionManager", propagation = Propagation.REQUIRED, rollbackFor = Exception.class)

How to return an Optional from MyBatis query

£可爱£侵袭症+ 提交于 2019-12-09 13:49:28
问题 Is there any way to get MyBatis to return an Optional<MyClass> instance rather than simply a MyClass instance? 回答1: Mybatis pre 3.5.0 Create custom ObjectFactory like this: class OptionalAwareObjectFactory extends DefaultObjectFactory { public Object create(Class type, List<Class> constructorArgTypes, List<Object> constructorArgs) { if (Optional.class.isAssignableFrom(type)) { return Optional.fromNullable(Iterables.getOnlyElement(constructorArgs)); } else { return super.create(type,

Spring with MyBatis: expected single matching bean but found 2

偶尔善良 提交于 2019-12-07 09:01:18
问题 I've been using Spring with MyBatis and it's been working really well for a single database. I ran into difficulties when trying to add another database (see reproducible example on Github). I'm using Spring Java configuration (i.e. not XML). Most of the examples I've seen show how to achieve this using XML. I have two data configuration classes (A & B) like this: @Configuration @MapperScan("io.woolford.database.mapper") public class DataConfigDatabaseA { @Bean(name="dataSourceA") public

Dynamic datasource routing - DataSource router not initialized

蹲街弑〆低调 提交于 2019-12-06 10:15:31
问题 I'm referring to this article, in which we can use the AbstractRoutingDataSource from Spring Framework to dynamically change the data source used by the application. I'm using Mybatis (3.3.0) with Spring (4.1.6.RELEASE). I want to switch to the backup database if exception occurs while getting data from main db. In this example, i have used hsql and mysql db. RoutingDataSource : public class RoutingDataSource extends AbstractRoutingDataSource { @Override protected Object