Package com.landawn.abacus.util
Class SQLMapper
- java.lang.Object
-
- com.landawn.abacus.util.SQLMapper
-
public final class SQLMapper extends Object
the sql scripts are configured in xml file and mapped to short ids referenced in program. for example:
<sqlMapper>
<sql id="findAccountById">select * from account where id=1</sql>
<sql id="updateAccountNameById">update account set name=? where id=?</sql>
</sqlMapper>
- Since:
- 0.8
- Author:
- Haiyang Li
-
-
Field Summary
Fields Modifier and Type Field Description static String
BATCH_SIZE
The Constant BATCH_SIZE.static String
FETCH_SIZE
The Constant FETCH_SIZE.static String
ID
The Constant ID.static int
MAX_ID_LENGTH
The Constant MAX_ID_LENGTH.static String
RESULT_SET_TYPE
The Constant RESULT_SET_TYPE.static ImmutableMap<String,Integer>
RESULT_SET_TYPE_MAP
The Constant RESULT_SET_TYPE_MAP.static String
SQL
The Constant SQL.static String
SQL_MAPPER
The Constant SQL_MAPPER.static String
TIMEOUT
The Constant TIMEOUT.
-
Constructor Summary
Constructors Constructor Description SQLMapper()
Instantiates a new SQL mapper.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ParsedSql
add(String id, ParsedSql sql)
void
add(String id, String sql, Map<String,String> attrs)
boolean
equals(Object obj)
static SQLMapper
fromFile(String filePath)
ParsedSql
get(String id)
ImmutableMap<String,String>
getAttrs(String id)
Gets the attrs.int
hashCode()
Set<String>
keySet()
void
remove(String id)
void
saveTo(File file)
String
toString()
-
-
-
Field Detail
-
SQL_MAPPER
public static final String SQL_MAPPER
The Constant SQL_MAPPER.- See Also:
- Constant Field Values
-
SQL
public static final String SQL
The Constant SQL.- See Also:
- Constant Field Values
-
ID
public static final String ID
The Constant ID.- See Also:
- Constant Field Values
-
BATCH_SIZE
public static final String BATCH_SIZE
The Constant BATCH_SIZE.- See Also:
- Constant Field Values
-
FETCH_SIZE
public static final String FETCH_SIZE
The Constant FETCH_SIZE.- See Also:
- Constant Field Values
-
RESULT_SET_TYPE
public static final String RESULT_SET_TYPE
The Constant RESULT_SET_TYPE.- See Also:
- Constant Field Values
-
RESULT_SET_TYPE_MAP
public static final ImmutableMap<String,Integer> RESULT_SET_TYPE_MAP
The Constant RESULT_SET_TYPE_MAP.
-
TIMEOUT
public static final String TIMEOUT
The Constant TIMEOUT.- See Also:
- Constant Field Values
-
MAX_ID_LENGTH
public static final int MAX_ID_LENGTH
The Constant MAX_ID_LENGTH.- See Also:
- Constant Field Values
-
-
Method Detail
-
fromFile
public static SQLMapper fromFile(String filePath)
- Parameters:
filePath
- it could be multiple file paths separated by ',' or ';'- Returns:
-
getAttrs
public ImmutableMap<String,String> getAttrs(String id)
Gets the attrs.- Parameters:
id
-- Returns:
-
add
public void add(String id, String sql, Map<String,String> attrs)
- Parameters:
id
-sql
-attrs
-
-
remove
public void remove(String id)
- Parameters:
id
-
-
saveTo
public void saveTo(File file)
- Parameters:
file
-
-
equals
public boolean equals(Object obj)
-
-