list) {
50 | for (Foo foo : list) {
51 | if (foo == null) {
52 | Assertions.fail("list contained a null element");
53 | }
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/test/java/com/ibatis/sqlmap/ResultObjectFactoryTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2023 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap;
17 |
18 | import static org.junit.jupiter.api.Assertions.assertEquals;
19 |
20 | import java.util.List;
21 |
22 | import org.junit.jupiter.api.BeforeEach;
23 | import org.junit.jupiter.api.Test;
24 |
25 | import testdomain.IItem;
26 |
27 | class ResultObjectFactoryTest extends BaseSqlMap {
28 |
29 | @BeforeEach
30 | void setUp() throws Exception {
31 | initSqlMap("com/ibatis/sqlmap/maps/SqlMapConfig_rof.xml", null);
32 | initScript("scripts/jpetstore-hsqldb-schema.sql");
33 | initScript("scripts/jpetstore-hsqldb-dataload.sql");
34 | }
35 |
36 | /**
37 | * This tests that the result object factory is working - everything in the sql map is declared as an interface.
38 | */
39 | @Test
40 | void testShouldDemonstrateThatTheObjectFactoryIsWorking() throws Exception {
41 | List> results = sqlMap.queryForList("getAllItemsROF");
42 | assertEquals(28, results.size());
43 | assertEquals(Integer.valueOf(1), ((IItem) results.get(2)).getSupplier().getSupplierId());
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/test/resources/scripts/account-init.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2004-2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | -- HSQL DATABASE
18 |
19 | -- Dropping Tables
20 |
21 | DROP TABLE ACCOUNT;
22 |
23 | -- Creating Tables
24 |
25 | CREATE TABLE ACCOUNT (
26 | ACC_ID INTEGER NOT NULL,
27 | ACC_FIRST_NAME VARCHAR(255) NOT NULL,
28 | ACC_LAST_NAME VARCHAR(255) NOT NULL,
29 | ACC_EMAIL VARCHAR(255),
30 | ACC_AGE NUMERIC,
31 | ACC_BANNER_OPTION VARCHAR(255),
32 | ACC_CART_OPTION INTEGER,
33 | ACC_DATE_ADDED DATE,
34 | PRIMARY KEY (ACC_ID)
35 | );
36 |
37 | -- Creating Test Data
38 |
39 | INSERT INTO ACCOUNT VALUES(1,'Clinton', 'Begin', 'clinton.begin@ibatis.com', 1, 'Aye', 200, CURRENT_DATE);
40 | INSERT INTO ACCOUNT VALUES(2,'Jim', 'Smith', 'jim.smith@somewhere.com', 2, 'Aye', 200, CURRENT_DATE);
41 | INSERT INTO ACCOUNT VALUES(3,'Elizabeth', 'Jones', null, 3, 'Nay', 100, CURRENT_DATE);
42 | INSERT INTO ACCOUNT VALUES(4,'Bob', 'Jackson', 'bob.jackson@somewhere.com', 4, 'Nay', 100, CURRENT_DATE);
43 | INSERT INTO ACCOUNT VALUES(5,'&manda', 'Goodman', null, 5, 'Aye', 100, CURRENT_DATE);
44 |
45 |
46 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/common/beans/MethodInvoker.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.common.beans;
17 |
18 | import java.lang.reflect.InvocationTargetException;
19 | import java.lang.reflect.Method;
20 |
21 | /**
22 | * The Class MethodInvoker.
23 | */
24 | public class MethodInvoker implements Invoker {
25 |
26 | /** The method. */
27 | private Method method;
28 |
29 | /** The name. */
30 | private String name;
31 |
32 | /**
33 | * Instantiates a new method invoker.
34 | *
35 | * @param method
36 | * the method
37 | */
38 | public MethodInvoker(Method method) {
39 | this.method = method;
40 | this.name = method.getName();
41 | }
42 |
43 | @Override
44 | public Object invoke(Object target, Object[] args) throws IllegalAccessException, InvocationTargetException {
45 | return method.invoke(target, args);
46 | }
47 |
48 | /**
49 | * Gets the method.
50 | *
51 | * @return the method
52 | */
53 | public Method getMethod() {
54 | return method;
55 | }
56 |
57 | @Override
58 | public String getName() {
59 | return name;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/common/xml/NodeletException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.common.xml;
17 |
18 | /**
19 | * The Class NodeletException.
20 | */
21 | public class NodeletException extends Exception {
22 |
23 | private static final long serialVersionUID = 1L;
24 |
25 | /**
26 | * Instantiates a new nodelet exception.
27 | */
28 | public NodeletException() {
29 | super();
30 | }
31 |
32 | /**
33 | * Instantiates a new nodelet exception.
34 | *
35 | * @param msg
36 | * the msg
37 | */
38 | public NodeletException(String msg) {
39 | super(msg);
40 | }
41 |
42 | /**
43 | * Instantiates a new nodelet exception.
44 | *
45 | * @param cause
46 | * the cause
47 | */
48 | public NodeletException(Throwable cause) {
49 | super(cause);
50 | }
51 |
52 | /**
53 | * Instantiates a new nodelet exception.
54 | *
55 | * @param msg
56 | * the msg
57 | * @param cause
58 | * the cause
59 | */
60 | public NodeletException(String msg, Throwable cause) {
61 | super(msg, cause);
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/sqlmap/engine/accessplan/MapAccessPlan.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap.engine.accessplan;
17 |
18 | import java.util.Map;
19 |
20 | /**
21 | * Access plan for working with Maps.
22 | */
23 | public class MapAccessPlan extends BaseAccessPlan {
24 |
25 | /**
26 | * Instantiates a new map access plan.
27 | *
28 | * @param clazz
29 | * the clazz
30 | * @param propertyNames
31 | * the property names
32 | */
33 | MapAccessPlan(Class clazz, String[] propertyNames) {
34 | super(clazz, propertyNames);
35 | }
36 |
37 | public void setProperties(Object object, Object[] values) {
38 | Map map = (Map) object;
39 | for (int i = 0; i < propertyNames.length; i++) {
40 | map.put(propertyNames[i], values[i]);
41 | }
42 | }
43 |
44 | public Object[] getProperties(Object object) {
45 | Object[] values = new Object[propertyNames.length];
46 | Map map = (Map) object;
47 | for (int i = 0; i < propertyNames.length; i++) {
48 | values[i] = map.get(propertyNames[i]);
49 | }
50 | return values;
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/sqlmap/engine/mapping/parameter/NoParameterMap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap.engine.mapping.parameter;
17 |
18 | import com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate;
19 | import com.ibatis.sqlmap.engine.scope.StatementScope;
20 |
21 | /**
22 | * The Class NoParameterMap.
23 | */
24 | public class NoParameterMap extends ParameterMap {
25 |
26 | /** The Constant NO_PARAMETERS. */
27 | private static final ParameterMapping[] NO_PARAMETERS = new ParameterMapping[0];
28 |
29 | /** The Constant NO_DATA. */
30 | private static final Object[] NO_DATA = new Object[0];
31 |
32 | /**
33 | * Instantiates a new no parameter map.
34 | *
35 | * @param delegate
36 | * the delegate
37 | */
38 | public NoParameterMap(SqlMapExecutorDelegate delegate) {
39 | super(delegate);
40 | }
41 |
42 | @Override
43 | public ParameterMapping[] getParameterMappings() {
44 | return NO_PARAMETERS;
45 | }
46 |
47 | @Override
48 | public Object[] getParameterObjectValues(StatementScope statementScope, Object parameterObject) {
49 | return NO_DATA;
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/sqlmap/client/event/RowHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap.client.event;
17 |
18 | /**
19 | * Event handler for row by row processing.
20 | *
21 | * The RowHandler interface is used by the SqlMapSession.queryWithRowHandler() method. Generally a RowHandler
22 | * implementation will perform some row-by-row processing logic in cases where there are too many rows to efficiently
23 | * load into memory.
24 | *
25 | * Example:
26 | *
27 | *
28 | * sqlMap.queryWithRowHandler ("findAllEmployees", null, new MyRowHandler()));
29 | *
30 | */
31 | public interface RowHandler {
32 |
33 | /**
34 | * Handles a single row of a result set.
35 | *
36 | * This method will be called for each row in a result set. For each row the result map will be applied to build the
37 | * value object, which is then passed in as the valueObject parameter.
38 | *
39 | * @param valueObject
40 | * The object representing a single row from the query.
41 | *
42 | * @see com.ibatis.sqlmap.client.SqlMapSession
43 | */
44 | void handleRow(Object valueObject);
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/sqlmap/engine/accessplan/EnhancedPropertyAccessPlan.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap.engine.accessplan;
17 |
18 | import net.sf.cglib.beans.BulkBean;
19 |
20 | /**
21 | * Enhanced PropertyAccessPlan (for working with beans using CG Lib).
22 | */
23 | public class EnhancedPropertyAccessPlan extends BaseAccessPlan {
24 |
25 | /** The bulk bean. */
26 | private BulkBean bulkBean;
27 |
28 | /**
29 | * Instantiates a new enhanced property access plan.
30 | *
31 | * @param clazz
32 | * the clazz
33 | * @param propertyNames
34 | * the property names
35 | */
36 | EnhancedPropertyAccessPlan(Class clazz, String[] propertyNames) {
37 | super(clazz, propertyNames);
38 | bulkBean = BulkBean.create(clazz, getGetterNames(propertyNames), getSetterNames(propertyNames),
39 | getTypes(propertyNames));
40 | }
41 |
42 | public void setProperties(Object object, Object[] values) {
43 | bulkBean.setPropertyValues(object, values);
44 | }
45 |
46 | public Object[] getProperties(Object object) {
47 | return bulkBean.getPropertyValues(object);
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/test/resources/threads/Foo-sql-map.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
22 |
23 |
24 |
27 | select * from foo
28 |
29 |
30 |
31 |
34 | select * from foo
35 |
36 |
37 |
38 | drop table foo if exists;
39 |
40 |
41 |
42 | create table foo (
43 | column1 varchar(50),
44 | column2 varchar(50),
45 | column3 varchar(50)
46 | );
47 |
48 |
49 |
50 | insert into foo values ('a', 'a', 'a');
51 |
52 |
53 |
54 | insert into foo values ('b', 'b', 'b');
55 |
56 |
57 |
58 | insert into foo values ('c', 'c', 'c');
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/src/test/java/com/ibatis/sqlmap/ComplexTypeTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap;
17 |
18 | import static org.junit.jupiter.api.Assertions.assertEquals;
19 |
20 | import java.util.HashMap;
21 | import java.util.Map;
22 |
23 | import org.junit.jupiter.api.BeforeEach;
24 | import org.junit.jupiter.api.Test;
25 |
26 | import testdomain.ComplexBean;
27 |
28 | class ComplexTypeTest extends BaseSqlMap {
29 |
30 | // SETUP & TEARDOWN
31 |
32 | @BeforeEach
33 | void setUp() throws Exception {
34 | initSqlMap("com/ibatis/sqlmap/maps/SqlMapConfig.xml", null);
35 | initScript("scripts/account-init.sql");
36 | initScript("scripts/order-init.sql");
37 | initScript("scripts/line_item-init.sql");
38 | }
39 |
40 | @Test
41 | void testMapBeanMap() throws Exception {
42 | Map map = new HashMap<>();
43 | ComplexBean bean = new ComplexBean();
44 | bean.setMap(new HashMap<>());
45 | bean.getMap().put("id", Integer.valueOf(1));
46 | map.put("bean", bean);
47 |
48 | Integer id = (Integer) sqlMap.queryForObject("mapBeanMap", map);
49 |
50 | assertEquals(id, bean.getMap().get("id"));
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/common/logging/jakarta/JakartaCommonsLoggingImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.common.logging.jakarta;
17 |
18 | import org.apache.commons.logging.Log;
19 | import org.apache.commons.logging.LogFactory;
20 |
21 | /**
22 | * The Class JakartaCommonsLoggingImpl.
23 | */
24 | public class JakartaCommonsLoggingImpl implements com.ibatis.common.logging.Log {
25 |
26 | /** The log. */
27 | private Log log;
28 |
29 | /**
30 | * Instantiates a new jakarta commons logging impl.
31 | *
32 | * @param clazz
33 | * the clazz
34 | */
35 | public JakartaCommonsLoggingImpl(Class clazz) {
36 | log = LogFactory.getLog(clazz);
37 | }
38 |
39 | @Override
40 | public boolean isDebugEnabled() {
41 | return log.isDebugEnabled();
42 | }
43 |
44 | @Override
45 | public void error(String s, Throwable e) {
46 | log.error(s, e);
47 | }
48 |
49 | @Override
50 | public void error(String s) {
51 | log.error(s);
52 | }
53 |
54 | @Override
55 | public void debug(String s) {
56 | log.debug(s);
57 | }
58 |
59 | @Override
60 | public void warn(String s) {
61 | log.warn(s);
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/common/logging/jdk14/Jdk14LoggingImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.common.logging.jdk14;
17 |
18 | import java.util.logging.Level;
19 | import java.util.logging.Logger;
20 |
21 | /**
22 | * The Class Jdk14LoggingImpl.
23 | */
24 | public class Jdk14LoggingImpl implements com.ibatis.common.logging.Log {
25 |
26 | /** The log. */
27 | private Logger log;
28 |
29 | /**
30 | * Instantiates a new jdk 14 logging impl.
31 | *
32 | * @param clazz
33 | * the clazz
34 | */
35 | public Jdk14LoggingImpl(Class clazz) {
36 | log = Logger.getLogger(clazz.getName());
37 | }
38 |
39 | @Override
40 | public boolean isDebugEnabled() {
41 | return log.isLoggable(Level.FINE);
42 | }
43 |
44 | @Override
45 | public void error(String s, Throwable e) {
46 | log.log(Level.SEVERE, s, e);
47 | }
48 |
49 | @Override
50 | public void error(String s) {
51 | log.log(Level.SEVERE, s);
52 | }
53 |
54 | @Override
55 | public void debug(String s) {
56 | log.log(Level.FINE, s);
57 | }
58 |
59 | @Override
60 | public void warn(String s) {
61 | log.log(Level.WARNING, s);
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/src/test/java/testdomain/IItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2023 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package testdomain;
17 |
18 | import java.math.BigDecimal;
19 |
20 | /**
21 | * Used in testing the ResultObjectFactory
22 | *
23 | * @author Jeff Butler
24 | */
25 | public interface IItem {
26 | String getAttribute1();
27 |
28 | void setAttribute1(String attribute1);
29 |
30 | String getAttribute2();
31 |
32 | void setAttribute2(String attribute2);
33 |
34 | String getAttribute3();
35 |
36 | void setAttribute3(String attribute3);
37 |
38 | String getAttribute4();
39 |
40 | void setAttribute4(String attribute4);
41 |
42 | String getAttribute5();
43 |
44 | void setAttribute5(String attribute5);
45 |
46 | String getItemId();
47 |
48 | void setItemId(String itemId);
49 |
50 | BigDecimal getListPrice();
51 |
52 | void setListPrice(BigDecimal listPrice);
53 |
54 | String getProductId();
55 |
56 | void setProductId(String productId);
57 |
58 | String getStatus();
59 |
60 | void setStatus(String status);
61 |
62 | ISupplier getSupplier();
63 |
64 | void setSupplier(ISupplier supplier);
65 |
66 | BigDecimal getUnitCost();
67 |
68 | void setUnitCost(BigDecimal unitCost);
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/sqlmap/engine/transaction/TransactionException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap.engine.transaction;
17 |
18 | /**
19 | * The Class TransactionException.
20 | */
21 | public class TransactionException extends Exception {
22 |
23 | /** The Constant serialVersionUID. */
24 | private static final long serialVersionUID = 1L;
25 |
26 | /**
27 | * Instantiates a new transaction exception.
28 | */
29 | public TransactionException() {
30 | }
31 |
32 | /**
33 | * Instantiates a new transaction exception.
34 | *
35 | * @param msg
36 | * the msg
37 | */
38 | public TransactionException(String msg) {
39 | super(msg);
40 | }
41 |
42 | /**
43 | * Instantiates a new transaction exception.
44 | *
45 | * @param cause
46 | * the cause
47 | */
48 | public TransactionException(Throwable cause) {
49 | super(cause);
50 | }
51 |
52 | /**
53 | * Instantiates a new transaction exception.
54 | *
55 | * @param msg
56 | * the msg
57 | * @param cause
58 | * the cause
59 | */
60 | public TransactionException(String msg, Throwable cause) {
61 | super(msg, cause);
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/src/test/java/testdomain/LineItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package testdomain;
17 |
18 | import java.io.Serializable;
19 | import java.math.BigDecimal;
20 |
21 | public class LineItem implements Serializable {
22 |
23 | private static final long serialVersionUID = 1L;
24 | private int id;
25 | private int orderId;
26 | private String itemCode;
27 | private int quantity;
28 | private BigDecimal price;
29 |
30 | public int getId() {
31 | return id;
32 | }
33 |
34 | public void setId(int id) {
35 | this.id = id;
36 | }
37 |
38 | public int getOrderId() {
39 | return orderId;
40 | }
41 |
42 | public void setOrderId(int orderId) {
43 | this.orderId = orderId;
44 | }
45 |
46 | public String getItemCode() {
47 | return itemCode;
48 | }
49 |
50 | public void setItemCode(String itemCode) {
51 | this.itemCode = itemCode;
52 | }
53 |
54 | public int getQuantity() {
55 | return quantity;
56 | }
57 |
58 | public void setQuantity(int quantity) {
59 | this.quantity = quantity;
60 | }
61 |
62 | public BigDecimal getPrice() {
63 | return price;
64 | }
65 |
66 | public void setPrice(BigDecimal price) {
67 | this.price = price;
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/src/test/java/testdomain/FieldAccount.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2023 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package testdomain;
17 |
18 | import java.io.Serializable;
19 |
20 | public class FieldAccount implements Serializable {
21 |
22 | private static final long serialVersionUID = 1L;
23 | private int id;
24 | private String firstName;
25 | private String lastName;
26 | private String emailAddress;
27 | private FieldAccount account;
28 |
29 | public int id() {
30 | return id;
31 | }
32 |
33 | public void id(int id) {
34 | this.id = id;
35 | }
36 |
37 | public String firstName() {
38 | return firstName;
39 | }
40 |
41 | public void firstName(String firstName) {
42 | this.firstName = firstName;
43 | }
44 |
45 | public String lastName() {
46 | return lastName;
47 | }
48 |
49 | public void lastName(String lastName) {
50 | this.lastName = lastName;
51 | }
52 |
53 | public String emailAddress() {
54 | return emailAddress;
55 | }
56 |
57 | public void emailAddress(String emailAddress) {
58 | this.emailAddress = emailAddress;
59 | }
60 |
61 | public FieldAccount account() {
62 | return account;
63 | }
64 |
65 | public void account(FieldAccount account) {
66 | this.account = account;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/.mvn/settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
21 |
22 |
23 |
24 |
25 | central
26 | ${env.CI_DEPLOY_USERNAME}
27 | ${env.CI_DEPLOY_PASSWORD}
28 |
29 |
30 |
31 |
32 | gh-pages-scm
33 |
34 | branch
35 | gh-pages
36 |
37 |
38 |
39 |
40 |
41 | github
42 | ${env.GITHUB_TOKEN}
43 |
44 |
45 |
46 |
47 | nvd
48 | ${env.NVD_API_KEY}
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/common/beans/ProbeException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.common.beans;
17 |
18 | /**
19 | * BeansException for use for by BeanProbe and StaticBeanProbe.
20 | */
21 | public class ProbeException extends RuntimeException {
22 |
23 | private static final long serialVersionUID = 1L;
24 |
25 | /**
26 | * Default constructor.
27 | */
28 | public ProbeException() {
29 | }
30 |
31 | /**
32 | * Constructor to set the message for the exception.
33 | *
34 | * @param msg
35 | * - the message for the exception
36 | */
37 | public ProbeException(String msg) {
38 | super(msg);
39 | }
40 |
41 | /**
42 | * Constructor to create a nested exception.
43 | *
44 | * @param cause
45 | * - the reason the exception is being thrown
46 | */
47 | public ProbeException(Throwable cause) {
48 | super(cause);
49 | }
50 |
51 | /**
52 | * Constructor to create a nested exception with a message.
53 | *
54 | * @param msg
55 | * - the message for the exception
56 | * @param cause
57 | * - the reason the exception is being thrown
58 | */
59 | public ProbeException(String msg, Throwable cause) {
60 | super(msg, cause);
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/common/xml/Nodelet.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.common.xml;
17 |
18 | import org.w3c.dom.Node;
19 |
20 | /**
21 | * A nodelet is a sort of callback or event handler that can be registered to handle an XPath event registered with the
22 | * NodeParser.
23 | */
24 | public interface Nodelet {
25 |
26 | /**
27 | * For a registered XPath, the NodeletParser will call the Nodelet's process method for processing.
28 | *
29 | * @param node
30 | * The node represents any XML node that can be registered under an XPath supported by the NodeletParser.
31 | * Possible nodes are:
32 | *
33 | * - Text - Use node.getNodeValue() for the text value.
34 | *
- Attribute - Use node.getNodeValue() for the attribute value.
35 | *
- Element - This is the most flexible type. You can get the node content and iterate over the node's
36 | * child nodes if neccessary. This is useful where a single XPath registration cannot describe the complex
37 | * structure for a given XML stanza.
38 | *
39 | *
40 | * @throws Exception
41 | * the exception
42 | */
43 | void process(Node node) throws Exception;
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/sqlmap/engine/accessplan/ComplexAccessPlan.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap.engine.accessplan;
17 |
18 | import com.ibatis.common.beans.Probe;
19 | import com.ibatis.common.beans.ProbeFactory;
20 |
21 | /**
22 | * Access plan for working with beans.
23 | */
24 | public class ComplexAccessPlan extends BaseAccessPlan {
25 |
26 | /** The Constant PROBE. */
27 | private static final Probe PROBE = ProbeFactory.getProbe();
28 |
29 | /**
30 | * Instantiates a new complex access plan.
31 | *
32 | * @param clazz
33 | * the clazz
34 | * @param propertyNames
35 | * the property names
36 | */
37 | ComplexAccessPlan(Class clazz, String[] propertyNames) {
38 | super(clazz, propertyNames);
39 | }
40 |
41 | public void setProperties(Object object, Object[] values) {
42 | for (int i = 0; i < propertyNames.length; i++) {
43 | PROBE.setObject(object, propertyNames[i], values[i]);
44 | }
45 | }
46 |
47 | public Object[] getProperties(Object object) {
48 | Object[] values = new Object[propertyNames.length];
49 | for (int i = 0; i < propertyNames.length; i++) {
50 | values[i] = PROBE.getObject(object, propertyNames[i]);
51 | }
52 | return values;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/test/resources/com/ibatis/sqlmap/maps/DerbyProc.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | {call MRESULTSET(#1#,#2#,#3#,#4#)}
38 |
39 |
40 |
41 | {call MRESULTSET(#1#,#2#,#3#,#4#)}
42 |
43 |
44 |
--------------------------------------------------------------------------------
/src/test/java/testdomain/Product.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package testdomain;
17 |
18 | import java.io.Serializable;
19 | import java.util.List;
20 |
21 | public class Product implements Serializable {
22 |
23 | private static final long serialVersionUID = 1L;
24 |
25 | private String productId;
26 | private String categoryId;
27 | private String name;
28 | private String description;
29 | private List> itemList;
30 |
31 | public String getProductId() {
32 | return productId;
33 | }
34 |
35 | public void setProductId(String productId) {
36 | this.productId = productId;
37 | }
38 |
39 | public String getCategoryId() {
40 | return categoryId;
41 | }
42 |
43 | public void setCategoryId(String categoryId) {
44 | this.categoryId = categoryId;
45 | }
46 |
47 | public String getName() {
48 | return name;
49 | }
50 |
51 | public void setName(String name) {
52 | this.name = name;
53 | }
54 |
55 | public String getDescription() {
56 | return description;
57 | }
58 |
59 | public void setDescription(String description) {
60 | this.description = description;
61 | }
62 |
63 | public List> getItemList() {
64 | return itemList;
65 | }
66 |
67 | public void setItemList(List> itemList) {
68 | this.itemList = itemList;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/sqlmap/engine/mapping/sql/dynamic/elements/IsEmptyTagHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap.engine.mapping.sql.dynamic.elements;
17 |
18 | import com.ibatis.common.beans.Probe;
19 | import com.ibatis.common.beans.ProbeFactory;
20 |
21 | import java.lang.reflect.Array;
22 | import java.util.Collection;
23 |
24 | /**
25 | * The Class IsEmptyTagHandler.
26 | */
27 | public class IsEmptyTagHandler extends ConditionalTagHandler {
28 |
29 | /** The Constant PROBE. */
30 | private static final Probe PROBE = ProbeFactory.getProbe();
31 |
32 | @Override
33 | public boolean isCondition(SqlTagContext ctx, SqlTag tag, Object parameterObject) {
34 | if (parameterObject == null) {
35 | return true;
36 | } else {
37 | String prop = getResolvedProperty(ctx, tag);
38 | Object value;
39 | if (prop != null) {
40 | value = PROBE.getObject(parameterObject, prop);
41 | } else {
42 | value = parameterObject;
43 | }
44 | if (value instanceof Collection) {
45 | return ((Collection) value).isEmpty();
46 | } else if (value != null && value.getClass().isArray()) {
47 | return Array.getLength(value) == 0;
48 | } else {
49 | return value == null || String.valueOf(value).equals("");
50 | }
51 | }
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/test/java/com/ibatis/sqlmap/DirectFieldMappingTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2023 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap;
17 |
18 | import java.sql.SQLException;
19 |
20 | import org.junit.jupiter.api.BeforeEach;
21 | import org.junit.jupiter.api.Test;
22 |
23 | import testdomain.FieldAccount;
24 | import testdomain.PrivateAccount;
25 |
26 | class DirectFieldMappingTest extends BaseSqlMap {
27 |
28 | @BeforeEach
29 | void setUp() throws Exception {
30 | initSqlMap("com/ibatis/sqlmap/maps/SqlMapConfig.xml", null);
31 | initScript("scripts/account-init.sql");
32 | }
33 |
34 | @Test
35 | void testInsertAndSelectDirectToFields() throws SQLException {
36 | FieldAccount account = newFieldAccount6();
37 |
38 | sqlMap.insert("insertAccountFromFields", account);
39 |
40 | account = (FieldAccount) sqlMap.queryForObject("getAccountToFields", Integer.valueOf(6));
41 |
42 | assertFieldAccount6(account);
43 | assertFieldAccount6(account.account());
44 | }
45 |
46 | @Test
47 | void testGetAccountWithPrivateConstructor() throws SQLException {
48 | FieldAccount account = newFieldAccount6();
49 |
50 | sqlMap.insert("insertAccountFromFields", account);
51 |
52 | PrivateAccount pvt = (PrivateAccount) sqlMap.queryForObject("getAccountWithPrivateConstructor", Integer.valueOf(6));
53 |
54 | assertPrivateAccount6(pvt);
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/test/java/testdomain/Category.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package testdomain;
17 |
18 | import java.io.Serializable;
19 | import java.util.List;
20 |
21 | public class Category implements Serializable {
22 |
23 | private static final long serialVersionUID = 1L;
24 | private String categoryId;
25 | private Category parentCategory;
26 | private String name;
27 | private String description;
28 | private List> productList;
29 |
30 | public String getCategoryId() {
31 | return categoryId;
32 | }
33 |
34 | public void setCategoryId(String categoryId) {
35 | this.categoryId = categoryId;
36 | }
37 |
38 | public String getName() {
39 | return name;
40 | }
41 |
42 | public void setName(String name) {
43 | this.name = name;
44 | }
45 |
46 | public String getDescription() {
47 | return description;
48 | }
49 |
50 | public void setDescription(String description) {
51 | this.description = description;
52 | }
53 |
54 | public List> getProductList() {
55 | return productList;
56 | }
57 |
58 | public void setProductList(List> productList) {
59 | this.productList = productList;
60 | }
61 |
62 | public Category getParentCategory() {
63 | return parentCategory;
64 | }
65 |
66 | public void setParentCategory(Category parentCategory) {
67 | this.parentCategory = parentCategory;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/common/beans/ProbeFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.common.beans;
17 |
18 | /**
19 | * An abstract factory for getting Probe implementations.
20 | */
21 | public class ProbeFactory {
22 |
23 | /** The Constant DOM. */
24 | private static final Probe DOM = new DomProbe();
25 |
26 | /** The Constant BEAN. */
27 | private static final Probe BEAN = new ComplexBeanProbe();
28 |
29 | /** The Constant GENERIC. */
30 | private static final Probe GENERIC = new GenericProbe();
31 |
32 | /**
33 | * Private constructor to prevent instantiation.
34 | */
35 | private ProbeFactory() {
36 | // Prevent instantiation
37 | }
38 |
39 | /**
40 | * Factory method for getting a Probe object.
41 | *
42 | * @return An implementation of the Probe interface
43 | */
44 | public static Probe getProbe() {
45 | return GENERIC;
46 | }
47 |
48 | /**
49 | * Factory method for getting a Probe object that is the best choice for the type of object supplied by the object
50 | * parameter.
51 | *
52 | * @param object
53 | * The object to get a Probe for
54 | *
55 | * @return An implementation of the Probe interface
56 | */
57 | public static Probe getProbe(Object object) {
58 | if (object instanceof org.w3c.dom.Document) {
59 | return DOM;
60 | }
61 | return BEAN;
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/sqlmap/engine/mapping/sql/stat/StaticSql.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap.engine.mapping.sql.stat;
17 |
18 | import com.ibatis.sqlmap.engine.mapping.parameter.ParameterMap;
19 | import com.ibatis.sqlmap.engine.mapping.result.ResultMap;
20 | import com.ibatis.sqlmap.engine.mapping.sql.Sql;
21 | import com.ibatis.sqlmap.engine.scope.StatementScope;
22 |
23 | /**
24 | * The Class StaticSql.
25 | */
26 | public class StaticSql implements Sql {
27 |
28 | /** The sql statement. */
29 | private String sqlStatement;
30 |
31 | /**
32 | * Instantiates a new static sql.
33 | *
34 | * @param sqlStatement
35 | * the sql statement
36 | */
37 | public StaticSql(String sqlStatement) {
38 | this.sqlStatement = sqlStatement.replace('\r', ' ').replace('\n', ' ');
39 | }
40 |
41 | @Override
42 | public String getSql(StatementScope statementScope, Object parameterObject) {
43 | return sqlStatement;
44 | }
45 |
46 | @Override
47 | public ParameterMap getParameterMap(StatementScope statementScope, Object parameterObject) {
48 | return statementScope.getParameterMap();
49 | }
50 |
51 | @Override
52 | public ResultMap getResultMap(StatementScope statementScope, Object parameterObject) {
53 | return statementScope.getResultMap();
54 | }
55 |
56 | @Override
57 | public void cleanup(StatementScope statementScope) {
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/sqlmap/engine/type/ClobTypeHandlerCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap.engine.type;
17 |
18 | import com.ibatis.sqlmap.client.extensions.ParameterSetter;
19 | import com.ibatis.sqlmap.client.extensions.ResultGetter;
20 | import com.ibatis.sqlmap.client.extensions.TypeHandlerCallback;
21 |
22 | import java.io.StringReader;
23 | import java.sql.Clob;
24 | import java.sql.SQLException;
25 | import java.sql.Types;
26 |
27 | /**
28 | * The Class ClobTypeHandlerCallback.
29 | */
30 | public class ClobTypeHandlerCallback implements TypeHandlerCallback {
31 |
32 | @Override
33 | public Object getResult(ResultGetter getter) throws SQLException {
34 | String value;
35 | Clob clob = getter.getClob();
36 | if (!getter.wasNull()) {
37 | int size = (int) clob.length();
38 | value = clob.getSubString(1, size);
39 | } else {
40 | value = null;
41 | }
42 |
43 | return value;
44 | }
45 |
46 | @Override
47 | public void setParameter(ParameterSetter setter, Object parameter) throws SQLException {
48 | String s = (String) parameter;
49 | if (s != null) {
50 | StringReader reader = new StringReader(s);
51 | setter.setCharacterStream(reader, s.length());
52 | } else {
53 | setter.setNull(Types.CLOB);
54 | }
55 | }
56 |
57 | @Override
58 | public Object valueOf(String s) {
59 | return s;
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/sqlmap/engine/transaction/Transaction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap.engine.transaction;
17 |
18 | import java.sql.Connection;
19 | import java.sql.SQLException;
20 |
21 | /**
22 | * The Interface Transaction.
23 | */
24 | public interface Transaction {
25 |
26 | /**
27 | * Commit.
28 | *
29 | * @throws SQLException
30 | * the SQL exception
31 | * @throws TransactionException
32 | * the transaction exception
33 | */
34 | void commit() throws SQLException, TransactionException;
35 |
36 | /**
37 | * Rollback.
38 | *
39 | * @throws SQLException
40 | * the SQL exception
41 | * @throws TransactionException
42 | * the transaction exception
43 | */
44 | void rollback() throws SQLException, TransactionException;
45 |
46 | /**
47 | * Close.
48 | *
49 | * @throws SQLException
50 | * the SQL exception
51 | * @throws TransactionException
52 | * the transaction exception
53 | */
54 | void close() throws SQLException, TransactionException;
55 |
56 | /**
57 | * Gets the connection.
58 | *
59 | * @return the connection
60 | *
61 | * @throws SQLException
62 | * the SQL exception
63 | * @throws TransactionException
64 | * the transaction exception
65 | */
66 | Connection getConnection() throws SQLException, TransactionException;
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/sqlmap/engine/type/BlobTypeHandlerCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap.engine.type;
17 |
18 | import com.ibatis.sqlmap.client.extensions.ParameterSetter;
19 | import com.ibatis.sqlmap.client.extensions.ResultGetter;
20 | import com.ibatis.sqlmap.client.extensions.TypeHandlerCallback;
21 |
22 | import java.io.ByteArrayInputStream;
23 | import java.sql.Blob;
24 | import java.sql.SQLException;
25 | import java.sql.Types;
26 |
27 | /**
28 | * The Class BlobTypeHandlerCallback.
29 | */
30 | public class BlobTypeHandlerCallback implements TypeHandlerCallback {
31 |
32 | @Override
33 | public Object getResult(ResultGetter getter) throws SQLException {
34 | Blob blob = getter.getBlob();
35 | byte[] returnValue;
36 | if (!getter.wasNull()) {
37 | returnValue = blob.getBytes(1, (int) blob.length());
38 | } else {
39 | returnValue = null;
40 | }
41 | return returnValue;
42 | }
43 |
44 | @Override
45 | public void setParameter(ParameterSetter setter, Object parameter) throws SQLException {
46 | if (null != parameter) {
47 | byte[] bytes = (byte[]) parameter;
48 | ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
49 | setter.setBinaryStream(bis, bytes.length);
50 | } else {
51 | setter.setNull(Types.BLOB);
52 | }
53 | }
54 |
55 | @Override
56 | public Object valueOf(String s) {
57 | return s;
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/sqlmap/engine/type/StringTypeHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap.engine.type;
17 |
18 | import java.sql.CallableStatement;
19 | import java.sql.PreparedStatement;
20 | import java.sql.ResultSet;
21 | import java.sql.SQLException;
22 |
23 | /**
24 | * String implementation of TypeHandler.
25 | */
26 | public class StringTypeHandler extends BaseTypeHandler implements TypeHandler {
27 |
28 | @Override
29 | public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException {
30 | ps.setString(i, (String) parameter);
31 | }
32 |
33 | @Override
34 | public Object getResult(ResultSet rs, String columnName) throws SQLException {
35 | Object s = rs.getString(columnName);
36 | if (rs.wasNull()) {
37 | return null;
38 | }
39 | return s;
40 | }
41 |
42 | @Override
43 | public Object getResult(ResultSet rs, int columnIndex) throws SQLException {
44 | Object s = rs.getString(columnIndex);
45 | if (rs.wasNull()) {
46 | return null;
47 | }
48 | return s;
49 | }
50 |
51 | @Override
52 | public Object getResult(CallableStatement cs, int columnIndex) throws SQLException {
53 | Object s = cs.getString(columnIndex);
54 | if (cs.wasNull()) {
55 | return null;
56 | }
57 | return s;
58 | }
59 |
60 | @Override
61 | public Object valueOf(String s) {
62 | return s;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/sqlmap/engine/type/ObjectTypeHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap.engine.type;
17 |
18 | import java.sql.CallableStatement;
19 | import java.sql.PreparedStatement;
20 | import java.sql.ResultSet;
21 | import java.sql.SQLException;
22 |
23 | /**
24 | * Object implementation of TypeHandler.
25 | */
26 | public class ObjectTypeHandler extends BaseTypeHandler implements TypeHandler {
27 |
28 | @Override
29 | public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException {
30 | ps.setObject(i, parameter);
31 | }
32 |
33 | @Override
34 | public Object getResult(ResultSet rs, String columnName) throws SQLException {
35 | Object object = rs.getObject(columnName);
36 | if (rs.wasNull()) {
37 | return null;
38 | }
39 | return object;
40 | }
41 |
42 | @Override
43 | public Object getResult(ResultSet rs, int columnIndex) throws SQLException {
44 | Object object = rs.getObject(columnIndex);
45 | if (rs.wasNull()) {
46 | return null;
47 | }
48 | return object;
49 | }
50 |
51 | @Override
52 | public Object getResult(CallableStatement cs, int columnIndex) throws SQLException {
53 | Object object = cs.getObject(columnIndex);
54 | if (cs.wasNull()) {
55 | return null;
56 | }
57 | return object;
58 | }
59 |
60 | @Override
61 | public Object valueOf(String s) {
62 | return s;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/sqlmap/engine/mapping/sql/raw/RawSql.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap.engine.mapping.sql.raw;
17 |
18 | import com.ibatis.sqlmap.engine.mapping.parameter.ParameterMap;
19 | import com.ibatis.sqlmap.engine.mapping.result.ResultMap;
20 | import com.ibatis.sqlmap.engine.mapping.sql.Sql;
21 | import com.ibatis.sqlmap.engine.scope.StatementScope;
22 |
23 | /**
24 | * A non-executable SQL container simply for communicating raw SQL around the framework.
25 | */
26 | public class RawSql implements Sql {
27 |
28 | /** The sql. */
29 | private String sql;
30 |
31 | /**
32 | * Instantiates a new raw sql.
33 | *
34 | * @param sql
35 | * the sql
36 | */
37 | public RawSql(String sql) {
38 | this.sql = sql;
39 | }
40 |
41 | @Override
42 | public String getSql(StatementScope statementScope, Object parameterObject) {
43 | return sql;
44 | }
45 |
46 | @Override
47 | public ParameterMap getParameterMap(StatementScope statementScope, Object parameterObject) {
48 | throw new RuntimeException("Method not implemented on RawSql.");
49 | }
50 |
51 | @Override
52 | public ResultMap getResultMap(StatementScope statementScope, Object parameterObject) {
53 | throw new RuntimeException("Method not implemented on RawSql.");
54 | }
55 |
56 | @Override
57 | public void cleanup(StatementScope statementScope) {
58 | throw new RuntimeException("Method not implemented on RawSql.");
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/sqlmap/engine/type/ByteArrayTypeHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap.engine.type;
17 |
18 | import java.sql.CallableStatement;
19 | import java.sql.PreparedStatement;
20 | import java.sql.ResultSet;
21 | import java.sql.SQLException;
22 |
23 | /**
24 | * byte[] implementation of TypeHandler.
25 | */
26 | public class ByteArrayTypeHandler extends BaseTypeHandler implements TypeHandler {
27 |
28 | @Override
29 | public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException {
30 | ps.setBytes(i, (byte[]) parameter);
31 | }
32 |
33 | @Override
34 | public Object getResult(ResultSet rs, String columnName) throws SQLException {
35 | Object bytes = rs.getBytes(columnName);
36 | if (rs.wasNull()) {
37 | return null;
38 | }
39 | return bytes;
40 | }
41 |
42 | @Override
43 | public Object getResult(ResultSet rs, int columnIndex) throws SQLException {
44 | Object bytes = rs.getBytes(columnIndex);
45 | if (rs.wasNull()) {
46 | return null;
47 | }
48 | return bytes;
49 | }
50 |
51 | @Override
52 | public Object getResult(CallableStatement cs, int columnIndex) throws SQLException {
53 | Object bytes = cs.getBytes(columnIndex);
54 | if (cs.wasNull()) {
55 | return null;
56 | }
57 | return bytes;
58 | }
59 |
60 | @Override
61 | public Object valueOf(String s) {
62 | return s.getBytes();
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/test/java/com/ibatis/common/beans/ComplexBeanProbeTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2023 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.common.beans;
17 |
18 | import static org.junit.jupiter.api.Assertions.assertEquals;
19 | import static org.junit.jupiter.api.Assertions.assertTrue;
20 | import static org.junit.jupiter.api.Assertions.fail;
21 |
22 | import org.junit.jupiter.api.Test;
23 |
24 | class ComplexBeanProbeTest {
25 |
26 | @Test
27 | void testSetObject() {
28 | SimpleClass mySimpleClass = new SimpleClass();
29 | Probe probe = ProbeFactory.getProbe(mySimpleClass);
30 | probe.setObject(mySimpleClass, "myInt", Integer.valueOf(1));
31 | assertEquals(1, mySimpleClass.getMyInt());
32 | probe.setObject(mySimpleClass, "myInt", Integer.valueOf(2));
33 | assertEquals(2, mySimpleClass.getMyInt());
34 | try {
35 | probe.setObject(mySimpleClass, "myInt", null);
36 | fail();
37 | } catch (RuntimeException e) {
38 | assertTrue(e.getMessage().contains("'myInt' to value 'null'"));
39 | }
40 | try {
41 | probe.setObject(mySimpleClass, "myInt", Float.valueOf(1.2f));
42 | fail();
43 | } catch (RuntimeException e) {
44 | assertTrue(e.getMessage().contains("'myInt' to value '1.2'"));
45 | }
46 | }
47 |
48 | public class SimpleClass {
49 |
50 | int myInt;
51 |
52 | public int getMyInt() {
53 | return myInt;
54 | }
55 |
56 | public void setMyInt(int myInt) {
57 | this.myInt = myInt;
58 | }
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/test/java/com/ibatis/sqlmap/engine/builder/xml/SqlMapConfigParserTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap.engine.builder.xml;
17 |
18 | import com.ibatis.common.resources.Resources;
19 |
20 | import java.io.IOException;
21 | import java.io.InputStreamReader;
22 |
23 | import org.junit.jupiter.api.Assertions;
24 | import org.junit.jupiter.api.Test;
25 |
26 | class SqlMapConfigParserTest {
27 | @Test
28 | void parseStream() throws IOException {
29 | SqlMapConfigParser parser = new SqlMapConfigParser();
30 | var stream = Resources.getResourceAsStream("com/ibatis/sqlmap/maps/SqlMapConfig.xml");
31 | final var sqlMapClient = parser.parse(stream); // fails
32 |
33 | Assertions.assertNotNull(sqlMapClient);
34 | }
35 |
36 | @Test
37 | void parseStreamToReader() throws IOException {
38 | SqlMapConfigParser parser = new SqlMapConfigParser();
39 | var stream = Resources.getResourceAsStream("com/ibatis/sqlmap/maps/SqlMapConfig.xml");
40 | var reader = new InputStreamReader(stream);
41 | final var sqlMapClient = parser.parse(reader);
42 |
43 | Assertions.assertNotNull(sqlMapClient);
44 | }
45 |
46 | @Test
47 | void parseReader() throws IOException {
48 | SqlMapConfigParser parser = new SqlMapConfigParser();
49 | var reader = Resources.getResourceAsReader("com/ibatis/sqlmap/maps/SqlMapConfig.xml");
50 | final var sqlMapClient = parser.parse(reader);
51 |
52 | Assertions.assertNotNull(sqlMapClient);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/sqlmap/engine/mapping/statement/DeleteStatement.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap.engine.mapping.statement;
17 |
18 | import com.ibatis.sqlmap.client.event.RowHandler;
19 | import com.ibatis.sqlmap.engine.scope.StatementScope;
20 | import com.ibatis.sqlmap.engine.transaction.Transaction;
21 |
22 | import java.sql.SQLException;
23 | import java.util.List;
24 |
25 | /**
26 | * The Class DeleteStatement.
27 | */
28 | public class DeleteStatement extends MappedStatement {
29 |
30 | @Override
31 | public StatementType getStatementType() {
32 | return StatementType.DELETE;
33 | }
34 |
35 | @Override
36 | public Object executeQueryForObject(StatementScope statementScope, Transaction trans, Object parameterObject,
37 | Object resultObject) throws SQLException {
38 | throw new SQLException("Delete statements cannot be executed as a query.");
39 | }
40 |
41 | @Override
42 | public List executeQueryForList(StatementScope statementScope, Transaction trans, Object parameterObject,
43 | int skipResults, int maxResults) throws SQLException {
44 | throw new SQLException("Delete statements cannot be executed as a query.");
45 | }
46 |
47 | @Override
48 | public void executeQueryWithRowHandler(StatementScope statementScope, Transaction trans, Object parameterObject,
49 | RowHandler rowHandler) throws SQLException {
50 | throw new SQLException("Delete statements cannot be executed as a query.");
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/sqlmap/engine/mapping/statement/UpdateStatement.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap.engine.mapping.statement;
17 |
18 | import com.ibatis.sqlmap.client.event.RowHandler;
19 | import com.ibatis.sqlmap.engine.scope.StatementScope;
20 | import com.ibatis.sqlmap.engine.transaction.Transaction;
21 |
22 | import java.sql.SQLException;
23 | import java.util.List;
24 |
25 | /**
26 | * The Class UpdateStatement.
27 | */
28 | public class UpdateStatement extends MappedStatement {
29 |
30 | @Override
31 | public StatementType getStatementType() {
32 | return StatementType.UPDATE;
33 | }
34 |
35 | @Override
36 | public Object executeQueryForObject(StatementScope statementScope, Transaction trans, Object parameterObject,
37 | Object resultObject) throws SQLException {
38 | throw new SQLException("Update statements cannot be executed as a query.");
39 | }
40 |
41 | @Override
42 | public List executeQueryForList(StatementScope statementScope, Transaction trans, Object parameterObject,
43 | int skipResults, int maxResults) throws SQLException {
44 | throw new SQLException("Update statements cannot be executed as a query.");
45 | }
46 |
47 | @Override
48 | public void executeQueryWithRowHandler(StatementScope statementScope, Transaction trans, Object parameterObject,
49 | RowHandler rowHandler) throws SQLException {
50 | throw new SQLException("Update statements cannot be executed as a query.");
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/sqlmap/engine/type/ByteTypeHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap.engine.type;
17 |
18 | import java.sql.CallableStatement;
19 | import java.sql.PreparedStatement;
20 | import java.sql.ResultSet;
21 | import java.sql.SQLException;
22 |
23 | /**
24 | * Byte implementation of TypeHandler.
25 | */
26 | public class ByteTypeHandler extends BaseTypeHandler implements TypeHandler {
27 |
28 | @Override
29 | public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException {
30 | ps.setByte(i, ((Byte) parameter).byteValue());
31 | }
32 |
33 | @Override
34 | public Object getResult(ResultSet rs, String columnName) throws SQLException {
35 | byte b = rs.getByte(columnName);
36 | if (rs.wasNull()) {
37 | return null;
38 | }
39 | return Byte.valueOf(b);
40 | }
41 |
42 | @Override
43 | public Object getResult(ResultSet rs, int columnIndex) throws SQLException {
44 | byte b = rs.getByte(columnIndex);
45 | if (rs.wasNull()) {
46 | return null;
47 | }
48 | return Byte.valueOf(b);
49 | }
50 |
51 | @Override
52 | public Object getResult(CallableStatement cs, int columnIndex) throws SQLException {
53 | byte b = cs.getByte(columnIndex);
54 | if (cs.wasNull()) {
55 | return null;
56 | }
57 | return Byte.valueOf(b);
58 | }
59 |
60 | @Override
61 | public Object valueOf(String s) {
62 | return Byte.valueOf(s);
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/sqlmap/engine/type/LongTypeHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap.engine.type;
17 |
18 | import java.sql.CallableStatement;
19 | import java.sql.PreparedStatement;
20 | import java.sql.ResultSet;
21 | import java.sql.SQLException;
22 |
23 | /**
24 | * Long implementation of TypeHandler.
25 | */
26 | public class LongTypeHandler extends BaseTypeHandler implements TypeHandler {
27 |
28 | @Override
29 | public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException {
30 | ps.setLong(i, ((Long) parameter).longValue());
31 | }
32 |
33 | @Override
34 | public Object getResult(ResultSet rs, String columnName) throws SQLException {
35 | long l = rs.getLong(columnName);
36 | if (rs.wasNull()) {
37 | return null;
38 | }
39 | return Long.valueOf(l);
40 | }
41 |
42 | @Override
43 | public Object getResult(ResultSet rs, int columnIndex) throws SQLException {
44 | long l = rs.getLong(columnIndex);
45 | if (rs.wasNull()) {
46 | return null;
47 | }
48 | return Long.valueOf(l);
49 | }
50 |
51 | @Override
52 | public Object getResult(CallableStatement cs, int columnIndex) throws SQLException {
53 | long l = cs.getLong(columnIndex);
54 | if (cs.wasNull()) {
55 | return null;
56 | }
57 | return Long.valueOf(l);
58 | }
59 |
60 | @Override
61 | public Object valueOf(String s) {
62 | return Long.valueOf(s);
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/test/resources/com/ibatis/sqlmap/maps/OracleProc.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | {call swap_email_address (?, ?, ?)}
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 | {call swap_email_address (?, ?, ?)}
43 |
44 |
45 |
46 | {call no_param_proc ()}
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/src/test/java/testdomain/ArticleIndexDenorm.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2023 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package testdomain;
17 |
18 | import java.io.Serializable;
19 |
20 | /**
21 | * Denormalized version of an toy ArticleIndex object.
22 | */
23 | public class ArticleIndexDenorm implements Serializable {
24 |
25 | private static final long serialVersionUID = 1L;
26 | private String categoryTitle;
27 |
28 | private String topicTitle;
29 |
30 | private String description;
31 |
32 | /**
33 | * @return Returns the categoryTitle.
34 | */
35 | public String getCategoryTitle() {
36 | return categoryTitle;
37 | }
38 |
39 | /**
40 | * @param categoryTitle
41 | * The categoryTitle to set.
42 | */
43 | public void setCategoryTitle(String categoryTitle) {
44 | this.categoryTitle = categoryTitle;
45 | }
46 |
47 | /**
48 | * @return Returns the description.
49 | */
50 | public String getDescription() {
51 | return description;
52 | }
53 |
54 | /**
55 | * @param description
56 | * The description to set.
57 | */
58 | public void setDescription(String description) {
59 | this.description = description;
60 | }
61 |
62 | /**
63 | * @return Returns the topicTitle.
64 | */
65 | public String getTopicTitle() {
66 | return topicTitle;
67 | }
68 |
69 | /**
70 | * @param topicTitle
71 | * The topicTitle to set.
72 | */
73 | public void setTopicTitle(String topicTitle) {
74 | this.topicTitle = topicTitle;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/sqlmap/engine/type/FloatTypeHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap.engine.type;
17 |
18 | import java.sql.CallableStatement;
19 | import java.sql.PreparedStatement;
20 | import java.sql.ResultSet;
21 | import java.sql.SQLException;
22 |
23 | /**
24 | * Float implementation of TypeHandler.
25 | */
26 | public class FloatTypeHandler extends BaseTypeHandler implements TypeHandler {
27 |
28 | @Override
29 | public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException {
30 | ps.setFloat(i, ((Float) parameter).floatValue());
31 | }
32 |
33 | @Override
34 | public Object getResult(ResultSet rs, String columnName) throws SQLException {
35 | float f = rs.getFloat(columnName);
36 | if (rs.wasNull()) {
37 | return null;
38 | }
39 | return Float.valueOf(f);
40 | }
41 |
42 | @Override
43 | public Object getResult(ResultSet rs, int columnIndex) throws SQLException {
44 | float f = rs.getFloat(columnIndex);
45 | if (rs.wasNull()) {
46 | return null;
47 | }
48 | return Float.valueOf(f);
49 | }
50 |
51 | @Override
52 | public Object getResult(CallableStatement cs, int columnIndex) throws SQLException {
53 | float f = cs.getFloat(columnIndex);
54 | if (cs.wasNull()) {
55 | return null;
56 | }
57 | return Float.valueOf(f);
58 | }
59 |
60 | @Override
61 | public Object valueOf(String s) {
62 | return Float.valueOf(s);
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/sqlmap/engine/type/ShortTypeHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap.engine.type;
17 |
18 | import java.sql.CallableStatement;
19 | import java.sql.PreparedStatement;
20 | import java.sql.ResultSet;
21 | import java.sql.SQLException;
22 |
23 | /**
24 | * Short implementation of TypeHandler.
25 | */
26 | public class ShortTypeHandler extends BaseTypeHandler implements TypeHandler {
27 |
28 | @Override
29 | public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException {
30 | ps.setShort(i, ((Short) parameter).shortValue());
31 | }
32 |
33 | @Override
34 | public Object getResult(ResultSet rs, String columnName) throws SQLException {
35 | short s = rs.getShort(columnName);
36 | if (rs.wasNull()) {
37 | return null;
38 | }
39 | return Short.valueOf(s);
40 | }
41 |
42 | @Override
43 | public Object getResult(ResultSet rs, int columnIndex) throws SQLException {
44 | short s = rs.getShort(columnIndex);
45 | if (rs.wasNull()) {
46 | return null;
47 | }
48 | return Short.valueOf(s);
49 | }
50 |
51 | @Override
52 | public Object getResult(CallableStatement cs, int columnIndex) throws SQLException {
53 | short s = cs.getShort(columnIndex);
54 | if (cs.wasNull()) {
55 | return null;
56 | }
57 | return Short.valueOf(s);
58 | }
59 |
60 | @Override
61 | public Object valueOf(String s) {
62 | return Short.valueOf(s);
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/sqlmap/engine/exchange/BaseDataExchange.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap.engine.exchange;
17 |
18 | import com.ibatis.sqlmap.engine.cache.CacheKey;
19 | import com.ibatis.sqlmap.engine.mapping.parameter.ParameterMap;
20 | import com.ibatis.sqlmap.engine.scope.StatementScope;
21 |
22 | /**
23 | * Base implementation for the DataExchange interface.
24 | */
25 | public abstract class BaseDataExchange implements DataExchange {
26 |
27 | /** The data exchange factory. */
28 | private DataExchangeFactory dataExchangeFactory;
29 |
30 | /**
31 | * Instantiates a new base data exchange.
32 | *
33 | * @param dataExchangeFactory
34 | * the data exchange factory
35 | */
36 | protected BaseDataExchange(DataExchangeFactory dataExchangeFactory) {
37 | this.dataExchangeFactory = dataExchangeFactory;
38 | }
39 |
40 | public CacheKey getCacheKey(StatementScope statementScope, ParameterMap parameterMap, Object parameterObject) {
41 | CacheKey key = new CacheKey();
42 | Object[] data = getData(statementScope, parameterMap, parameterObject);
43 | for (int i = 0; i < data.length; i++) {
44 | if (data[i] != null) {
45 | key.update(data[i]);
46 | }
47 | }
48 | return key;
49 | }
50 |
51 | /**
52 | * Getter for the factory that created this object.
53 | *
54 | * @return - the factory
55 | */
56 | public DataExchangeFactory getDataExchangeFactory() {
57 | return dataExchangeFactory;
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/com/ibatis/sqlmap/engine/type/IntegerTypeHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.ibatis.sqlmap.engine.type;
17 |
18 | import java.sql.CallableStatement;
19 | import java.sql.PreparedStatement;
20 | import java.sql.ResultSet;
21 | import java.sql.SQLException;
22 |
23 | /**
24 | * Integer Decimal implementation of TypeHandler.
25 | */
26 | public class IntegerTypeHandler extends BaseTypeHandler implements TypeHandler {
27 |
28 | @Override
29 | public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException {
30 | ps.setInt(i, ((Integer) parameter).intValue());
31 | }
32 |
33 | @Override
34 | public Object getResult(ResultSet rs, String columnName) throws SQLException {
35 | int i = rs.getInt(columnName);
36 | if (rs.wasNull()) {
37 | return null;
38 | }
39 | return Integer.valueOf(i);
40 | }
41 |
42 | @Override
43 | public Object getResult(ResultSet rs, int columnIndex) throws SQLException {
44 | int i = rs.getInt(columnIndex);
45 | if (rs.wasNull()) {
46 | return null;
47 | }
48 | return Integer.valueOf(i);
49 | }
50 |
51 | @Override
52 | public Object getResult(CallableStatement cs, int columnIndex) throws SQLException {
53 | int i = cs.getInt(columnIndex);
54 | if (cs.wasNull()) {
55 | return null;
56 | }
57 | return Integer.valueOf(i);
58 | }
59 |
60 | @Override
61 | public Object valueOf(String s) {
62 | return Integer.valueOf(s);
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------