Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion src/main/java/org/mybatis/logging/Logger.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2022 the original author or authors.
* Copyright 2010-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,30 +26,69 @@
*/
public class Logger {

/** The log. */
private final Log log;

/**
* Instantiates a new logger.
*
* @param log
* the log
*/
Logger(Log log) {
this.log = log;
}

/**
* Error.
*
* @param s
* the s
* @param e
* the e
*/
public void error(Supplier<String> s, Throwable e) {
log.error(s.get(), e);
}

/**
* Error.
*
* @param s
* the s
*/
public void error(Supplier<String> s) {
log.error(s.get());
}

/**
* Warn.
*
* @param s
* the s
*/
public void warn(Supplier<String> s) {
log.warn(s.get());
}

/**
* Debug.
*
* @param s
* the s
*/
public void debug(Supplier<String> s) {
if (log.isDebugEnabled()) {
log.debug(s.get());
}
}

/**
* Trace.
*
* @param s
* the s
*/
public void trace(Supplier<String> s) {
if (log.isTraceEnabled()) {
log.trace(s.get());
Expand Down
21 changes: 20 additions & 1 deletion src/main/java/org/mybatis/logging/LoggerFactory.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2022 the original author or authors.
* Copyright 2010-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,14 +24,33 @@
*/
public class LoggerFactory {

/**
* Instantiates a new logger factory.
*/
private LoggerFactory() {
// NOP
}

/**
* Gets the logger.
*
* @param aClass
* the a class
*
* @return the logger
*/
public static Logger getLogger(Class<?> aClass) {
return new Logger(LogFactory.getLog(aClass));
}

/**
* Gets the logger.
*
* @param logger
* the logger
*
* @return the logger
*/
public static Logger getLogger(String logger) {
return new Logger(LogFactory.getLog(logger));
}
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/org/mybatis/spring/MyBatisSystemException.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2023 the original author or authors.
* Copyright 2010-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,11 +31,27 @@ public class MyBatisSystemException extends UncategorizedDataAccessException {

private static final long serialVersionUID = -5284728621670758939L;

/**
* Instantiates a new my batis system exception.
*
* @param cause
* the cause
*
* @deprecated as of 3.0.4, use {@link #MyBatisSystemException(String, Throwable)} instead
*/
@Deprecated(since = "3.0.4", forRemoval = true)
public MyBatisSystemException(Throwable cause) {
this(cause.getMessage(), cause);
}

/**
* Instantiates a new my batis system exception.
*
* @param msg
* the msg
* @param cause
* the cause
*/
public MyBatisSystemException(String msg, Throwable cause) {
super(msg, cause);
}
Expand Down
17 changes: 16 additions & 1 deletion src/main/java/org/mybatis/spring/SqlSessionHolder.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2022 the original author or authors.
* Copyright 2010-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -59,14 +59,29 @@ public SqlSessionHolder(SqlSession sqlSession, ExecutorType executorType,
this.exceptionTranslator = exceptionTranslator;
}

/**
* Gets the sql session.
*
* @return the sql session
*/
public SqlSession getSqlSession() {
return sqlSession;
}

/**
* Gets the executor type.
*
* @return the executor type
*/
public ExecutorType getExecutorType() {
return executorType;
}

/**
* Gets the persistence exception translator.
*
* @return the persistence exception translator
*/
public PersistenceExceptionTranslator getPersistenceExceptionTranslator() {
return exceptionTranslator;
}
Expand Down
17 changes: 16 additions & 1 deletion src/main/java/org/mybatis/spring/SqlSessionTemplate.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2024 the original author or authors.
* Copyright 2010-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -132,14 +132,29 @@ public SqlSessionTemplate(SqlSessionFactory sqlSessionFactory, ExecutorType exec
new Class[] { SqlSession.class }, new SqlSessionInterceptor());
}

/**
* Gets the sql session factory.
*
* @return the sql session factory
*/
public SqlSessionFactory getSqlSessionFactory() {
return this.sqlSessionFactory;
}

/**
* Gets the executor type.
*
* @return the executor type
*/
public ExecutorType getExecutorType() {
return this.executorType;
}

/**
* Gets the persistence exception translator.
*
* @return the persistence exception translator
*/
public PersistenceExceptionTranslator getPersistenceExceptionTranslator() {
return this.exceptionTranslator;
}
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/org/mybatis/spring/annotation/MapperScan.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2024 the original author or authors.
* Copyright 2010-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,7 +40,6 @@
* the class that declares this annotation.
* <p>
* Configuration example:
* </p>
*
* <pre class="code">
* &#064;Configuration
Expand Down Expand Up @@ -168,7 +167,6 @@
* Whether enable lazy initialization of mapper bean.
* <p>
* Default is {@code false}.
* </p>
*
* @return set {@code true} to enable lazy initialization
*
Expand All @@ -180,7 +178,6 @@
* Specifies the default scope of scanned mappers.
* <p>
* Default is {@code ""} (equiv to singleton).
* </p>
*
* @return the default scope
*/
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/org/mybatis/spring/annotation/MapperScans.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2022 the original author or authors.
* Copyright 2010-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -41,5 +41,11 @@
@Documented
@Import(MapperScannerRegistrar.RepeatingRegistrar.class)
public @interface MapperScans {

/**
* Value.
*
* @return the mapper scan[]
*/
MapperScan[] value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
*
* @author Eduardo Macarron
*
* @param <T>
* the generic type
*
* @since 1.1.0
*/
public class MyBatisBatchItemWriter<T> implements ItemWriter<T>, InitializingBean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@
import org.springframework.beans.factory.InitializingBean;

/**
* {@code ItemReader} that uses MyBatis Cursor to read data.
*
* @author Guillaume Darmont / guillaume@dropinocean.com
*
* @param <T>
* the generic type
*/
public class MyBatisCursorItemReader<T> extends AbstractItemCountingItemStreamItemReader<T>
implements InitializingBean {
Expand All @@ -48,6 +53,9 @@ public class MyBatisCursorItemReader<T> extends AbstractItemCountingItemStreamIt
private Cursor<T> cursor;
private Iterator<T> cursorIterator;

/**
* Instantiates a new my batis cursor item reader.
*/
public MyBatisCursorItemReader() {
setName(getShortName(MyBatisCursorItemReader.class));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@
import org.springframework.batch.infrastructure.item.database.AbstractPagingItemReader;

/**
* {@code org.springframework.batch.item.ItemReader} for reading database records using MyBatis in a paging fashion.
* {@code org.springframework.batch.infrastructure.item.ItemReader} for reading database records using MyBatis in a
* paging fashion.
* <p>
* Provided to facilitate the migration from Spring-Batch iBATIS 2 page item readers to MyBatis 3.
*
* @author Eduardo Macarron
*
* @param <T>
* the generic type
*
* @since 1.1.0
*/
public class MyBatisPagingItemReader<T> extends AbstractPagingItemReader<T> {
Expand All @@ -51,6 +55,9 @@ public class MyBatisPagingItemReader<T> extends AbstractPagingItemReader<T> {

private Supplier<Map<String, Object>> parameterValuesSupplier;

/**
* Instantiates a new my batis paging item reader.
*/
public MyBatisPagingItemReader() {
setName(getShortName(MyBatisPagingItemReader.class));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2024 the original author or authors.
* Copyright 2010-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,6 +27,9 @@
*
* @author Kazuki Shimizu
*
* @param <T>
* the generic type
*
* @since 2.0.0
*
* @see MyBatisBatchItemWriter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2024 the original author or authors.
* Copyright 2010-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,6 +27,9 @@
*
* @author Kazuki Shimizu
*
* @param <T>
* the generic type
*
* @since 2.0.0
*
* @see MyBatisCursorItemReader
Expand Down Expand Up @@ -104,15 +107,15 @@ public MyBatisCursorItemReaderBuilder<T> parameterValuesSupplier(
}

/**
* Configure if the state of the {@link org.springframework.batch.item.ItemStreamSupport} should be persisted within
* the {@link org.springframework.batch.item.ExecutionContext} for restart purposes.
* Configure if the state of the {@link org.springframework.batch.infrastructure.item.ItemStreamSupport} should be
* persisted within the {@link org.springframework.batch.infrastructure.item.ExecutionContext} for restart purposes.
*
* @param saveState
* defaults to true
*
* @return The current instance of the builder.
*
* @see org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader#setSaveState(boolean)
* @see org.springframework.batch.infrastructure.item.support.AbstractItemCountingItemStreamItemReader#setSaveState(boolean)
*/
public MyBatisCursorItemReaderBuilder<T> saveState(boolean saveState) {
this.saveState = saveState;
Expand All @@ -127,7 +130,7 @@ public MyBatisCursorItemReaderBuilder<T> saveState(boolean saveState) {
*
* @return The current instance of the builder.
*
* @see org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader#setMaxItemCount(int)
* @see org.springframework.batch.infrastructure.item.support.AbstractItemCountingItemStreamItemReader#setMaxItemCount(int)
*/
public MyBatisCursorItemReaderBuilder<T> maxItemCount(int maxItemCount) {
this.maxItemCount = maxItemCount;
Expand Down
Loading