SICIDatabase Protocol Reference
Conforms to | NSObject |
---|---|
Declared in | SICIDatabase.h |
Overview
Exposes methods to deal with actual database object. It has methods to open, create, close, and execute query’s.
– createTable
required method
Is used to create a new table in an database.
- (void)createTable
Discussion
Is used to create a new table in an database.
Using SIMINOV there are three ways to create table in database.
- Describing table structure in form of ENTITY-DESCRIPTOR XML file. And creation of table will be handled by SIMINOV.
SIMINOV will parse each ENTITY-DESCRIPTOR XML defined by developer and create table’s in database.
Example:
<!-- Design Of EntityDescriptor.xml -->
<entity-descriptor>
<!-- General Properties Of Table And Class -->
<!-- Mandatory Field -->
<!-- NAME OF TABLE -->
<property name="table_name">name_of_table</property>
<!-- Mandatory Field -->
<!-- MAPPED CLASS NAME -->
<property name="class_name">mapped_class_name</property>
<!-- Optional Field -->
<attributes>
<!-- Column Properties Required Under This Table -->
<!-- Optional Field -->
<attribute>
<!-- Mandatory Field -->
<!-- COLUMN_NAME: Mandatory Field -->
<property name="column_name">column_name_of_table</property>
<!-- Mandatory Field -->
<!-- VARIABLE_NAME: Mandatory Field -->
<property name="variable_name">class_variable_name</property>
<!-- Mandatory Field -->
<property name="type">java_variable_data_type</property>
<!-- Optional Field (Default is false) -->
<property name="primary_key">true/false</property>
<!-- Optional Field (Default is false) -->
<property name="not_null">true/false</property>
<!-- Optional Field (Default is false) -->
<property name="unique">true/false</property>
<!-- Optional Field -->
<property name="check">condition_to_be_checked (Eg: variable_name 'condition' value; variable_name > 0)</property>
<!-- Optional Field -->
<property name="default">default_value_of_column (Eg: 0.1)</property>
</attribute>
</attributes>
<!-- Optional Field -->
<indexes>
<!-- Index Properties -->
<index>
<!-- Mandatory Field -->
<!-- NAME OF INDEX -->
<property name="name">name_of_index</property>
<!-- Mandatory Field -->
<!-- UNIQUE: Optional Field (Default is false) -->
<property name="unique">true/false</property>
<!-- Optional Field -->
<!-- Name of the column -->
<property name="column">column_name_needs_to_add</property>
</index>
</indexes>
<!-- Map Relationship Properties -->
<!-- Optional Field's -->
<relationships>
<relationship>
<!-- Mandatory Field -->
<!-- Type of Relationship -->
<property name="type">one-to-one|one-to-many|many-to-one|many-to-many</property>
<!-- Mandatory Field -->
<!-- REFER -->
<property name="refer">class_variable_name</property>
<!-- Mandatory Field -->
<!-- REFER TO -->
<property name="refer_to">map_to_class_name</property>
<!-- Optional Field -->
<property name="on_update">cascade/restrict/no_action/set_null/set_default</property>
<!-- Optional Field -->
<property name="on_delete">cascade/restrict/no_action/set_null/set_default</property>
<!-- Optional Field (Default is false) -->
<property name="load">true/false</property>
</relationship>
</relationships>
</entity-descriptor>
Declared In
SICIDatabase.h
– dropTable
required method
It drop’s the table from database based on entity-descriptor.
- (void)dropTable
Discussion
It drop’s the table from database based on entity-descriptor.
Drop the Book table.
Book *book = [[Book alloc] init];
@try {
[book dropTable];
} @catch(SICDatabaseException *databaseException) {
//Log It.
}
Declared In
SICIDatabase.h
– dropIndex:
required method
Is used to drop a index on a table in database.
- (void)dropIndex:(NSString *)indexName
Parameters
indexName |
Name of a index needs to be drop. |
---|
Discussion
Is used to drop a index on a table in database.
Create Index On Book table.
NSString * indexName = @"BOOK_INDEX_BASED_ON_AUDITOR";
Book *book = [[Book alloc] init];
@try {
[book dropIndex:indexName];
} @catch(SICDatabaseException *databaseException) {
//Log It.
}
Declared In
SICIDatabase.h
– select
required method
Returns all tuples based on query from mapped table for invoked class object.
- (id<SICISelect>)select
Return Value
SICISelect object.
Discussion
Returns all tuples based on query from mapped table for invoked class object.
Example:
NSArray *books;
@try {
books = [[[[Book alloc] init] select] execute];
} @catch(SICDatabaseException de) {
//Log it.
}
Declared In
SICIDatabase.h
– select:
required method
Returns all tuples based on manual query from mapped table for invoked class object.
- (id)select:(NSString *)query
Parameters
query |
Query to get tuples from database. |
---|
Return Value
SICISelect object.
Discussion
Returns all tuples based on manual query from mapped table for invoked class object.
Example:
NSString *query = @"SELECT * FROM BOOK";
NSArray *books;
@try {
books = [[[Book alloc] init] select:query];
} @catch(SICDatabaseException *de) {
//Log it.
}
Declared In
SICIDatabase.h
– save
required method
It adds a record to any single table in a relational database.
- (void)save
Discussion
It adds a record to any single table in a relational database.
Example: Make Book Object
Book *cBook = [[Book alloc] init];
[cBook setTitle: BOOK_TYPE_C];
[cBook setDescription: @"c_description"];
[cBook setAuditor: @"c_auditor"];
[cBook setLink: @"c_link"];
@try {
[cBook save];
} @catch(SICDatabaseException *databaseException) {
//Log it.
}
Declared In
SICIDatabase.h
– update
required method
It updates a record to any single table in a relational database.
- (void)update
Discussion
It updates a record to any single table in a relational database.
Example: Make Beer Object
Book *cBook = [[Book alloc] init];
[cBook setTitle: BOOK_TYPE_C];
[cBook setDescription: @"c_description"];
[cBook setAuditor: @"c_auditor"];
[cBook setLink: @"beer_link"];
@try {
[cBook update];
} @catch(SICDatabaseException *databaseException) {
//Log it.
}
Declared In
SICIDatabase.h
– saveOrUpdate
required method
It finds out whether tuple exists in table or not. IF NOT EXISTS: adds a record to any single table in a relational database. ELSE: updates a record to any single table in a relational database.
- (void)saveOrUpdate
Discussion
It finds out whether tuple exists in table or not. IF NOT EXISTS: adds a record to any single table in a relational database. ELSE: updates a record to any single table in a relational database.
Example: Make Beer Object
Book *cBook = [[Book alloc] init];
[cBook setTitle: BOOK_TYPE_C];
[cBook setDescription: @"c_description"];
[cBook setHistory: @"c_auditor"];
[cBook setLink: @"c_link"];
@try {
[cBook saveOrUpdate];
} @catch(SICDatabaseException *databaseException) {
//Log it.
}
Declared In
SICIDatabase.h
– delete
required method
It deletes a record from single table in a relational database.
- (id<SICIDelete>)delete
Discussion
It deletes a record from single table in a relational database.
Example: Make Beer Object
Book *cBook = [[Book alloc] init];
[cBook setTitle: BOOK_TYPE_C];
[cBook setDescription: @"c_description"];
[cBook setAuditor: @"c_auditor"];
[cBook setLink: @"c_link"];
@try {
[cBook delete];
} @catch(SICDatabaseException *databaseException) {
//Log it.
}
Declared In
SICIDatabase.h
– count
required method
Returns the count of rows based on where clause provided.
- (id<SICICount>)count
Discussion
Returns the count of rows based on where clause provided.
Example: Make Beer Object
Book *cBook = [[Book alloc] init];
[cBook setTitle: BOOK_TYPE_C];
[cBook setDescription: @"c_description"];
[cBook setAuditor: @"c_auditor"];
[cBook setLink: @"c_link"];
int noOfBooks = 0;
@try {
noOfBooks = [[cBook count] execute];
} @catch(SICDatabaseException *databaseException) {
//Log it.
}
Declared In
SICIDatabase.h
– avg
required method
Returns the average based on where clause provided.
- (id<SICIAverage>)avg
Discussion
Returns the average based on where clause provided.
Example: Make Beer Object
Book *cBook = [[Book alloc] init];
[cBook setTitle: BOOK_TYPE_C];
[cBook setDescription: @"c_description"];
[cBook setAuditor: @"c_auditor"];
[cBook setLink: @"c_link"];
int noOfBooks = 0;
@try {
noOfBooks = [[beer avg] execute];
} @catch(SICDatabaseException *databaseException) {
//Log it.
}
Declared In
SICIDatabase.h
– sum
required method
Returns the sum based on where clause provided.
- (id<SICISum>)sum
Discussion
Returns the sum based on where clause provided.
Example: Make Beer Object
Book *cBook = [[Book alloc] init];
[cBook setTitle: BOOK_TYPE_C];
[cBook setDescription: @"c_description"];
[cBook setAuditor: @"c_auditor"];
[cBook setLink: @"c_link"];
int noOfBooks = 0;
@try {
noOfBooks = [[cBook sum] execute];
} @catch(SICDatabaseException *databaseException) {
//Log it.
}
Declared In
SICIDatabase.h
– total
required method
Returns the total based on where clause provided.
- (id<SICITotal>)total
Discussion
Returns the total based on where clause provided.
Example: Make Beer Object
Book *cBook = [[Book alloc] init];
[cBook setTitle:BOOK_TYPE_C];
[cBook setDescription: @"c_description"];
[cBook setAuditor: @"c_auditor"];
[cBook setLink: @"c_link"];
int totalBooks = 0;
@try {
totalBooks = [[cBook avg] execute];
}
@catch(SICDatabaseException *databaseException) {
//Log it.
}
Declared In
SICIDatabase.h
– min
required method
Returns the min based on where clause provided.
- (id<SICIMin>)min
Discussion
Returns the min based on where clause provided.
Example: Make Book Object
Book *cBook = [[Book alloc] init];
[cBook setTitle: BOOK_TYPE_C];
[cBook setDescription: @"c_description"];
[cBook setAuditor: @"c_auditor"];
[cBook setLink: @"c_link"];
int minBooks = 0;
@try {
minBooks = [[cBook min] execute];
} @catch(SICDatabaseException *databaseException) {
//Log it.
}
Declared In
SICIDatabase.h
– max
required method
Returns the max based on where clause provided.
- (id<SICIMax>)max
Discussion
Returns the max based on where clause provided.
Example: Make Beer Object
Book *cBook = [[Book alloc] init];
[cBook setTitle: Book.BOOK_TYPE_C];
[cBook setDescription: @"c_description"];
[cBook setAuditor: @"c_auditor"];
[cBook setLink: @"c_link"];
int maxBooks = 0;
@try {
maxBooks = [[cBook max] execute];
} @catch(SICDatabaseException *databaseException) {
//Log it.
}
Declared In
SICIDatabase.h
– groupConcat
required method
Returns the group concat based on where clause provided.
- (id<SICIGroupConcat>)groupConcat
Discussion
Returns the group concat based on where clause provided.
Example: Make Beer Object
Book *cBook = [[Book alloc] init];
[cBook setTitle: BOOK_TYPE_C];
[cBook setDescription: @"c_description"];
[cBook setAuditor: @"c_auditor"];
[cBook setLink: @"c_link"];
int groupConcatBooks = 0;
@try {
groupConcatBooks = [[cBook groupConcat] execute];
} @catch(SICDatabaseException *databaseException) {
//Log it.
}
Declared In
SICIDatabase.h
– getDatabaseDescriptor
required method
Returns database descriptor object based on the mapped class called.
- (SICDatabaseDescriptor *)getDatabaseDescriptor
Return Value
Database Descriptor Object.
Discussion
Returns database descriptor object based on the mapped class called.
Example:
@try {
SICDatabaseDescriptor *databaseDescriptor = [[[Book alloc] init] getDatabaseDescriptor];
} @catch(SICDatabaseException *databaseException) {
//Log It.
}
Declared In
SICIDatabase.h
– getEntityDescriptor
required method
Returns the actual entity descriptor object mapped for invoked class object.
- (SICEntityDescriptor *)getEntityDescriptor
Return Value
Entity Descriptor Object
Discussion
Returns the actual entity descriptor object mapped for invoked class object.
Example:
SICEntityDescriptor *entityDescriptor = nil;
@try {
entityDescriptor = [[[Book alloc] init] getEntityDescriptor];
} @catch(SICDatabaseException *databaseException) {
//Log it.
}
Declared In
SICIDatabase.h
– getTableName
required method
Returns the mapped table name for invoked class object.
- (NSString *)getTableName
Return Value
Mapped Table name.
Discussion
Returns the mapped table name for invoked class object.
Example:
NSString *tableName = nil;
@try {
tableName = [[[Book alloc] init] getTableName];
} @catch(SICDatabaseException *databaseException) {
//Log it.
}
Declared In
SICIDatabase.h
– getColumnNames
required method
Returns all column names of mapped table.
- (NSEnumerator *)getColumnNames
Return Value
All column names of mapped table.
Discussion
Returns all column names of mapped table.
Example:
NSEnumerator *columnNames = nil;
@try {
columnNames = [[[Book alloc] init] getColumnNames];
} @catch(SICDatabaseException *databaseException) {
//Log it.
}
Declared In
SICIDatabase.h
– getColumnValues
required method
Returns all column values in the same order of column names for invoked class object.
- (NSDictionary *)getColumnValues
Return Value
All column values for invoked object.
Discussion
Returns all column values in the same order of column names for invoked class object.
Example:
NSDictionary *values = nil;
@try {
values = [[[Book alloc] init] getColumnValues];
} @catch(SICDatabaseException *databaseException) {
//Log it.
}
Declared In
SICIDatabase.h
– getColumnTypes
required method
Returns all columns with there data types for invoked class object.
- (NSDictionary *)getColumnTypes
Return Value
All columns with there data types.
Discussion
Returns all columns with there data types for invoked class object.
Example:
NSDictionary columnTypes = nil; @try { columnTypes = [[[Book alloc] init] getColumnTypes]; } @catch(SICDatabaseException databaseException) { //Log it. }
Declared In
SICIDatabase.h
– getPrimaryKeys
required method
Returns all primary keys of mapped table for invoked class object.
- (NSEnumerator *)getPrimaryKeys
Return Value
All primary keys.
Discussion
Returns all primary keys of mapped table for invoked class object.
Example:
NSEnumerator *primaryKeys = nil;
@try {
primaryKeys = [[[Book alloc] init] getPrimaryKeys];
} @catch(SICDatabaseException *databaseException) {
//Log it.
}
Declared In
SICIDatabase.h
– getMandatoryFields
required method
Returns all mandatory fields which are associated with mapped table for invoked class object.
- (NSEnumerator *)getMandatoryFields
Return Value
All mandatory fields for mapped table.
Discussion
Returns all mandatory fields which are associated with mapped table for invoked class object.
Example:
NSEnumerator *mandatoryFields = nil;
@try {
mandatoryFields = [[[Book alloc] init] getMandatoryFields];
} @catch(SICDatabaseException *databaseException) {
//Log it.
}
Declared In
SICIDatabase.h
– getUniqueFields
required method
Returns all unique fields which are associated with mapped table for invoked class object.
- (NSEnumerator *)getUniqueFields
Return Value
All unique fields for mapped table.
Discussion
Returns all unique fields which are associated with mapped table for invoked class object.
Example:
NSEnumerator *uniqueFields = null;
@try {
uniqueFields = [[[Book alloc] init] getUniqueFields];
}
@catch(SICDatabaseException *databaseException) {
//Log it.
}
Declared In
SICIDatabase.h
– getForeignKeys
required method
Returns all foreign keys of mapped table for invoked class object.
- (NSEnumerator *)getForeignKeys
Return Value
All foreign keys of mapped table.
Discussion
Returns all foreign keys of mapped table for invoked class object.
Example:
NSEnumerator *foreignKeys = nil;
@try {
foreignKeys = [[[Book alloc] init] getForeignKeys];
} @catch(SICDatabaseException *databaseException) {
//Log it.
}
Declared In
SICIDatabase.h