|
Software Development Kit to the Delphi-Win32 and Free Pascal compilers |
| Home > Wiki > Persistence |
Persistenceenglish (en) | português (br)
[edit] PressObjects OPFTo use the PressObjects persistence framework, include at least one of it's connection brokers in the uses clause of a project file. Currently PressObjects has brokers for IBX, UIB, DOA, ZeosDBO, FBLib and SQLdb. The OPF article provides more information about the PressOPF framework. The following example uses a project unit 'Broker.pas' to manage database-specific tasks. unit Broker; uses PressIBXBroker; This declaration registers the IBX broker service, but doesn't configure the database name, username, password and any other required information. To do so, the connection brokers give you read access to the database connection component that can be reached using one of the following approaches: [edit] Using a configuration fileSee Configuration file for details. [edit] Creating the connection service
initialization
with TPressIBXBroker.Create.Connector.Database do
begin
DatabaseName := 'servername:c:\path\to\database';
Params.Values['user_name'] := 'sysdba';
Params.Values['password'] := 'masterkey';
// any other TIBDatabase property
end;
Don't worry about destroying the service, the PressObjects SDK will do it for you. [edit] Overriding the default IBX connection service
interface
type
TMyConnectionBroker = class(TPressIBXBroker)
protected
procedure InitService; override;
// any other TPressIBXBroker or TPressOPFBroker virtual method
end;
implementation
procedure TMyConnectionBroker.InitService;
begin
inherited;
with Connector.Database do
begin
DatabaseName := 'servername:c:\path\to\database';
Params.Values['user_name'] := 'sysdba';
Params.Values['password'] := 'masterkey';
// any other TIBDatabase property
end;
end;
initialization
TMyConnectionBroker.RegisterService(True);
Don't worry about creating or destroying the service, the PressObjects SDK will do it for you when necessary. The initialization section declaration is mandatory, it registers your customized service as the default OPF broker service. [edit] InstantObjectsTo use InstantObjects (IO), at least two units must be added to the uses clause of any project file. One must be 'PressInstantObjectsBroker', the other one must be one of the IO broker units (eg 'InstantIBX') for database access. IO Notes:
To use InstantObjects persistence, create an IO model with the same class names used in the PressObjects' model. |
Personal tools |