diff --git a/src/test/java/org/apache/ibatis/submitted/record_type/CreateDB.sql b/src/test/java/org/apache/ibatis/submitted/record_type/CreateDB.sql deleted file mode 100644 index c82ceb0f3f4..00000000000 --- a/src/test/java/org/apache/ibatis/submitted/record_type/CreateDB.sql +++ /dev/null @@ -1,32 +0,0 @@ --- --- Copyright 2009-2022 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. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- 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. --- - -drop table prop if exists; - -create table prop ( - id int, - val varchar(20), - url varchar(32) -); - -insert into prop (id, val, url) values (1, 'Val1', 'https://www.google.com'); - -create table item ( - id int, - prop_id int -); - -insert into item (id, prop_id) values (100, 1); diff --git a/src/test/java/org/apache/ibatis/submitted/record_type/Item.java b/src/test/java/org/apache/ibatis/submitted/record_type/Item.java deleted file mode 100644 index 9b3f073f7f5..00000000000 --- a/src/test/java/org/apache/ibatis/submitted/record_type/Item.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 2009-2022 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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.record_type; - -public record Item(Integer id, Property property) { -} diff --git a/src/test/java/org/apache/ibatis/submitted/record_type/Property.java b/src/test/java/org/apache/ibatis/submitted/record_type/Property.java deleted file mode 100644 index 9c1b76f94ff..00000000000 --- a/src/test/java/org/apache/ibatis/submitted/record_type/Property.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2009-2022 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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.record_type; - -public record Property(int id, String value, String URL) { - public String value() { - // Differentiate between method call and field access - return value + "!"; - } -} diff --git a/src/test/java/org/apache/ibatis/submitted/record_type/RecordTypeMapper.java b/src/test/java/org/apache/ibatis/submitted/record_type/RecordTypeMapper.java deleted file mode 100644 index 1bd58c63750..00000000000 --- a/src/test/java/org/apache/ibatis/submitted/record_type/RecordTypeMapper.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2009-2022 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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.record_type; - -import org.apache.ibatis.annotations.Arg; -import org.apache.ibatis.annotations.Insert; -import org.apache.ibatis.annotations.Results; -import org.apache.ibatis.annotations.Select; - -public interface RecordTypeMapper { - - @Select("select id, val, url from prop where id = #{id}") - Property selectPropertyAutomapping(int id); - - @Results(id = "propertyRM") - @Arg(column = "id", javaType = int.class) - @Arg(column = "val", javaType = String.class) - @Arg(column = "url", javaType = String.class) - @Select("select val, id, url from prop where id = #{id}") - Property selectProperty(int id); - - @Insert("insert into prop (id, val, url) values (#{id}, #{value}, #{URL})") - int insertProperty(Property property); - - @Arg(id = true, column = "id", javaType = Integer.class) - @Arg(javaType = Property.class, resultMap = "propertyRM", columnPrefix = "p_") - @Select({ - "select i.id, p.id p_id, p.val p_val, p.url p_url", - "from item i left join prop p on p.id = i.prop_id", - "where i.id = #{id}" }) - Item selectItem(Integer id); - -} diff --git a/src/test/java/org/apache/ibatis/submitted/record_type/RecordTypeTest.java b/src/test/java/org/apache/ibatis/submitted/record_type/RecordTypeTest.java deleted file mode 100644 index 2ed2ed13bd4..00000000000 --- a/src/test/java/org/apache/ibatis/submitted/record_type/RecordTypeTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2009-2022 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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.record_type; - -import static org.junit.jupiter.api.Assertions.*; - -import java.io.Reader; - -import org.apache.ibatis.BaseDataTest; -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; - -class RecordTypeTest { - - private static SqlSessionFactory sqlSessionFactory; - - @BeforeAll - static void setUp() throws Exception { - // create a SqlSessionFactory - try (Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/record_type/mybatis-config.xml")) { - sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader); - } - // populate in-memory database - BaseDataTest.runScript(sqlSessionFactory.getConfiguration().getEnvironment().getDataSource(), - "org/apache/ibatis/submitted/record_type/CreateDB.sql"); - } - - @Test - void testSelectRecord() { - try (SqlSession sqlSession = sqlSessionFactory.openSession()) { - RecordTypeMapper mapper = sqlSession.getMapper(RecordTypeMapper.class); - Property prop = mapper.selectProperty(1); - assertEquals("Val1!", prop.value()); - assertEquals("https://www.google.com", prop.URL()); - } - } - - @Test - void testSelectRecordAutomapping() { - try (SqlSession sqlSession = sqlSessionFactory.openSession()) { - RecordTypeMapper mapper = sqlSession.getMapper(RecordTypeMapper.class); - Property prop = mapper.selectPropertyAutomapping(1); - assertEquals("Val1!", prop.value()); - assertEquals("https://www.google.com", prop.URL()); - } - } - - @Test - void testInsertRecord() { - try (SqlSession sqlSession = sqlSessionFactory.openSession()) { - RecordTypeMapper mapper = sqlSession.getMapper(RecordTypeMapper.class); - assertEquals(1, mapper.insertProperty(new Property(2, "Val2", "https://mybatis.org"))); - sqlSession.commit(); - } - try (SqlSession sqlSession = sqlSessionFactory.openSession()) { - RecordTypeMapper mapper = sqlSession.getMapper(RecordTypeMapper.class); - Property prop = mapper.selectProperty(2); - assertEquals("Val2!!", prop.value()); - assertEquals("https://mybatis.org", prop.URL()); - } - } - - @Test - void testSelectNestedRecord() { - try (SqlSession sqlSession = sqlSessionFactory.openSession()) { - RecordTypeMapper mapper = sqlSession.getMapper(RecordTypeMapper.class); - Item item = mapper.selectItem(100); - assertEquals(Integer.valueOf(100), item.id()); - assertEquals(new Property(1, "Val1", "https://www.google.com"), item.property()); - } - } -} diff --git a/src/test/java/org/apache/ibatis/submitted/record_type/mybatis-config.xml b/src/test/java/org/apache/ibatis/submitted/record_type/mybatis-config.xml deleted file mode 100644 index a36d78cf853..00000000000 --- a/src/test/java/org/apache/ibatis/submitted/record_type/mybatis-config.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - -