-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathData.java
More file actions
154 lines (133 loc) · 5.31 KB
/
Copy pathData.java
File metadata and controls
154 lines (133 loc) · 5.31 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*******************************************************************************
* Copyright (c) 2013, 2025 James M. ZHOU
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package org.tinystruct.data;
import org.tinystruct.ApplicationException;
import org.tinystruct.data.component.Condition;
import org.tinystruct.data.component.Row;
import org.tinystruct.data.component.Table;
/**
* This interface defines methods for data operations.
*/
public interface Data {
/**
* Get the class path of the data object.
*/
String getClassPath();
/**
* Get the class name of the data object.
*/
String getClassName();
/**
* Set the database table associated with the data object.
*/
void setTableName(String attribute);
/**
* Set the identifier of the data object.
*/
Object setId(Object Id);
/**
* Get the identifier of the data object.
*/
Object getId();
/**
* Append a new record to the database.
* @return true if the operation is successful, false otherwise.
* @throws ApplicationException if an application-specific error occurs.
*/
boolean append() throws ApplicationException;
/**
* Append a new record to the database and return the generated ID.
* @return the generated ID if the operation is successful, null otherwise.
* @throws ApplicationException if an application-specific error occurs.
*/
Object appendAndGetId() throws ApplicationException;
/**
* Update an existing record in the database.
* @return true if the operation is successful, false otherwise.
* @throws ApplicationException if an application-specific error occurs.
*/
boolean update() throws ApplicationException;
/**
* Delete a record from the database.
* @return true if the operation is successful, false otherwise.
* @throws ApplicationException if an application-specific error occurs.
*/
boolean delete() throws ApplicationException;
/**
* Set the request fields for querying data.
*/
Data setRequestFields(String fields);
/**
* Set the order by clause for querying data.
*/
Data orderBy(String[] fieldNames);
/**
* Find records in the database based on the given SQL query and parameters.
* @param SQL the SQL query.
* @param parameters the parameters for the query.
* @return a Table containing the query result.
* @throws ApplicationException if an application-specific error occurs.
*/
Table find(String SQL, Object[] parameters) throws ApplicationException;
/**
* Find records in the database based on the given condition and parameters.
* @param condition the condition for the query.
* @param parameters the parameters for the query.
* @return a Table containing the query result.
* @throws ApplicationException if an application-specific error occurs.
*/
Table find(Condition condition, Object[] parameters) throws ApplicationException;
/**
* Find records in the database based on the given where clause and parameters.
* @param where the where clause for the query.
* @param parameters the parameters for the query.
* @return a Table containing the query result.
* @throws ApplicationException if an application-specific error occurs.
*/
Table findWith(String where, Object[] parameters) throws ApplicationException;
/**
* Find a single record in the database based on the given SQL query and parameters.
* @param SQL the SQL query.
* @param parameters the parameters for the query.
* @return a Row containing the query result.
* @throws ApplicationException if an application-specific error occurs.
*/
Row findOne(String SQL, Object[] parameters) throws ApplicationException;
/**
* Find a single record in the database by its identifier.
* @return a Row containing the query result.
* @throws ApplicationException if an application-specific error occurs.
*/
Row findOneById() throws ApplicationException;
/**
* Find a single record in the database by the given primary key and value.
* @param PK the primary key.
* @param value the value of the primary key.
* @return a Row containing the query result.
* @throws ApplicationException if an application-specific error occurs.
*/
Row findOneByKey(String PK, String value) throws ApplicationException;
/**
* Find all records in the database.
* @return a Table containing all records.
* @throws ApplicationException if an application-specific error occurs.
*/
Table findAll() throws ApplicationException;
/**
* Get the repository associated with the data object.
*/
Repository getRepository();
}