KOW Ent¶
KOW Ent is an Object abstraction layer to Relational databases. It creates SQL queries for inserting, searching and updating data from what we call Properties.
In other words, KOW Ent turn this:
declare
type My_Entity_Type is new KOW_Ent.Entity_Type with record
Name : Unbounded_String;
When : KOW_Ent.Extra_Properties.Timestamp;
Related_ID : KOW_Ent.Id_Type;
end record;
My : My_Entity_Type;
begin
KOW_Ent.Load( My, 1 );
KOW_Ent.Name := To_Unbounded_String( "My new Name!" );
KOW_Ent.Store( My );
end;
Into:
SELECT id,name,when,related_id from my_entities where id=1; UPDATE my_entities set name="My new Name!" where id=1;
Also, as it relies on APQ for insert quoted strings and all other data types are converted into Ada2005 types before the SQL call you can be sure your code will be safe from SQL-injection attacks.
Status¶
While the KOW Ent library is considered quite stable and is being used by several KOW projects (including www.metarrevisor.com.br and www.teca.etc.br) there are several things planned to be implemented in the Refactoring.
This refactoring should change some aspects of the API and is being taken place at the same time other libraries and applications are being implemented.
Even thought that's not the industry standard for working with source code, we have noticed this approach, even thought at some level chaotic, delivers high quality systems that have been proven over time. It can take longer, though.
Why there is no Delete method?¶
Yes, it is quite easy to implement such method for all databases using ANSI SQL. And yes, some times it is even needed. But we have chosen not to implement a delete method so the user will always thing of data as permanent elements.
This leads to a more consistent database overtime. Imagine if you can delete products from your database and when you want to generate a sales report from last year you can't find the products as they no longer exist in your catalog and thus in your database.
Instead of providing a delete method we implemented the KOW_Ent.Expirable_Entity_Controllers package.
Expirable Entity Controllers¶
This generic package implements a validation entity for each one of it's instances. This validation entity is used to determine when the data has been available.
Thanks to the Object Oriented design of KOW Ent you can then extend this validation entity to implement some temporal values, such as product price.
For instance:
type My_Price_Type is new My_Product_Controllers.Validation_Entity with record
Price : KOW_Ent.Extra_Properties.Money;
end record;
When you store a My_Price_Type variable KOW_Ent also creates the equivalent My_Product_Controllers.Validation_Entity entry.
This can be extended to any level, so you can then also implement a My_Price_With_Discount_Type that includes a discount for every purchase and so on.
This approach is actually implemented in the KOW ERP.