Skip to content

Commit

Permalink
write a line into test.file
Browse files Browse the repository at this point in the history
  • Loading branch information
huifer committed Mar 28, 2024
1 parent 29e89d2 commit 4f86391
Show file tree
Hide file tree
Showing 13 changed files with 874 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/spring/cs8db1329a-eca3-11ee-be36-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Copyright 2009-2015 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* <p>
* Contains the result processing logic
*/
/**
* Contains the result processing logic
*/
package org.apache.ibatis.executor.resultset;
90 changes: 90 additions & 0 deletions docs/spring/cs8e0022e2-eca3-11ee-be36-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/**
* Copyright 2009-2019 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.ibatis.submitted.nested_query_cache;

import org.apache.ibatis.BaseDataTest;
import org.apache.ibatis.domain.blog.Author;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import java.io.Reader;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;

class NestedQueryCacheTest extends BaseDataTest {

private static SqlSessionFactory sqlSessionFactory;

@BeforeAll
static void setUp() throws Exception {
// create a SqlSessionFactory
try (Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/nested_query_cache/MapperConfig.xml")) {
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
}

createBlogDataSource();
}

@Test
void testThatNestedQueryItemsAreRetrievedFromCache() {
final Author author;
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
final AuthorMapper authorMapper = sqlSession.getMapper(AuthorMapper.class);
author = authorMapper.selectAuthor(101);

// ensure that author is cached
final Author cachedAuthor = authorMapper.selectAuthor(101);
assertThat(author).isSameAs(cachedAuthor);
}

// open a new session
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
final BlogMapper blogMapper = sqlSession.getMapper(BlogMapper.class);

// ensure that nested author within blog is cached
assertThat(blogMapper.selectBlog(1).getAuthor()).isSameAs(author);
assertThat(blogMapper.selectBlogUsingConstructor(1).getAuthor()).isSameAs(author);
}
}

@Test
void testThatNestedQueryItemsAreRetrievedIfNotInCache() {
Author author;
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
final BlogMapper blogMapper = sqlSession.getMapper(BlogMapper.class);
author = blogMapper.selectBlog(1).getAuthor();

// ensure that nested author within blog is cached
assertNotNull(blogMapper.selectBlog(1).getAuthor(), "blog author");
assertNotNull(blogMapper.selectBlogUsingConstructor(1).getAuthor(), "blog author");
}

// open a new session
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
final AuthorMapper authorMapper = sqlSession.getMapper(AuthorMapper.class);
Author cachedAuthor = authorMapper.selectAuthor(101);

// ensure that nested author within blog is cached
assertThat(cachedAuthor).isSameAs(author);
}

}
}
32 changes: 32 additions & 0 deletions docs/spring/cs8e51f234-eca3-11ee-be36-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright 2009-2019 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.ibatis.executor;

import org.apache.ibatis.transaction.Transaction;
import org.junit.jupiter.api.Test;

class CachingSimpleExecutorTest extends BaseExecutorTest {

@Test
void dummy() {
}

@Override
protected Executor createExecutor(Transaction transaction) {
return new CachingExecutor(new SimpleExecutor(config, transaction));
}

}
38 changes: 38 additions & 0 deletions docs/spring/cs8ea8f958-eca3-11ee-be36-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright 2009-2019 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.ibatis.annotations;

import java.lang.annotation.*;

/**
* The maker annotation that invoke a flush statements via Mapper interface.
*
* <p><br>
* <b>How to use:</b>
* <pre>
* public interface UserMapper {
* &#064;Flush
* List&lt;BatchResult&gt; flush();
* }
* </pre>
* @since 3.3.0
* @author Kazuki Shimizu
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Flush {
}
67 changes: 67 additions & 0 deletions docs/spring/cs8efbe848-eca3-11ee-be36-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* Copyright 2009-2019 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.ibatis.autoconstructor;

public class ExtensiveSubject {
private final byte aByte;
private final short aShort;
private final char aChar;
private final int anInt;
private final long aLong;
private final float aFloat;
private final double aDouble;
private final boolean aBoolean;
private final String aString;

// enum types
private final TestEnum anEnum;

// array types

// string to lob types:
private final String aClob;
private final String aBlob;

public ExtensiveSubject(final byte aByte,
final short aShort,
final char aChar,
final int anInt,
final long aLong,
final float aFloat,
final double aDouble,
final boolean aBoolean,
final String aString,
final TestEnum anEnum,
final String aClob,
final String aBlob) {
this.aByte = aByte;
this.aShort = aShort;
this.aChar = aChar;
this.anInt = anInt;
this.aLong = aLong;
this.aFloat = aFloat;
this.aDouble = aDouble;
this.aBoolean = aBoolean;
this.aString = aString;
this.anEnum = anEnum;
this.aClob = aClob;
this.aBlob = aBlob;
}

public enum TestEnum {
AVALUE, BVALUE, CVALUE
}
}
Loading

0 comments on commit 4f86391

Please sign in to comment.