-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNSDaoCacheManager.java
More file actions
81 lines (73 loc) · 2.21 KB
/
Copy pathNSDaoCacheManager.java
File metadata and controls
81 lines (73 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package com.nullspace.dao;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import com.nullspace.dao.NSConnOperator.ConnResult;
import com.nullspace.dao.NSConnOperator.ConnResultList;
import com.nullspace.dao.bean.NSSqlViewObject;
/*
*
* 1 t_object 表
* int objId 唯一索引
* string className
*
* 2 t_object_filed 表
* int id
* int objId foreign key t_object
* int sortId 表字段的index
* int type 字段类型
*
* 3 t_sql (所需参数,客户端传递)
* int sqlId primary key
* string objIds(foreign, 以','分割)
* string sql_statement
*
* 4 t_sql_param (暂时不需要配置表,使用 pb 文件配置即可)
* int id
* int sqlId(foreign key)
* int paramType
* int paramIndex
* string value
* */
public class NSDaoCacheManager
{
static Map<String, NSConnParameterList> mParamCache = new HashMap<>();
static Map<Integer, NSSqlViewObject> mSqlCache = new HashMap<>();
public static void RegisterParamLst(Class<? extends NSConnRecordObject> clazz, NSConnParameterList lst)
{
mParamCache.put(clazz.toString(), lst);
}
public static NSConnParameterList GetParamLst(Class<? extends NSConnRecordObject> clazz)
{
return mParamCache.get(clazz.toString());
}
public static void Initialize()
{
try
{
ConnResultList result = NSConnOperator.instance.new ConnResultList();
Connection connection = NSDaoPoolManager.instance.AquireConnection();
ConnResult flag = NSConnOperator.instance.Execute(connection, "select sql_id, object_ids, sql_statement, sql_type from t_sql_view;", NSConnOperator.ConnOperatorType.T_QUERY, null, result);
if (flag.mFlag)
{
NSConnResultSet resultSet = NSConnOperator.instance.CreateTableObject(result.Get(0), NSSqlViewObject.class);
ArrayList<NSConnRecordObject> objects = resultSet.GetObjects();
for (NSConnRecordObject obj : objects)
{
System.out.println(obj);
NSSqlViewObject sqlObject = (NSSqlViewObject)obj;
mSqlCache.put(sqlObject.mSqlId, sqlObject);
}
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static NSSqlViewObject Get(int sqlId)
{
return mSqlCache.get(sqlId);
}
}