About the SQLServer DBExpress Adapter.

38 views
Skip to first unread message

Claudio Regonat

unread,
Jan 31, 2012, 5:18:23 PM1/31/12
to dorm, The Delphi ORM
Hi Guys,

so, i've got some time to test the DBExpress SQLServer adapter with
the last changes
and it works ok. The only thing that I've changed is that "Prepared
SQL" must be set to
true in dbxdrivers.ini.

Saludos, Claudio.

Marcos Barreto

unread,
Jan 31, 2012, 7:59:25 PM1/31/12
to dorm-the-...@googlegroups.com
Claudio I would like let the adapter more flexibles man, but danielle have others things to do!

What u think about discuss about how we could refactor the adpaters to make more simples create new adapters and
define generic and specif sql generators to reduce the code duplicated?

Claudio Regonat

unread,
Feb 1, 2012, 6:33:46 AM2/1/12
to dorm, The Delphi ORM
Marcos,

I agree with you about refactor of the adapters, i think that they
must be more generics
then the support of other databases would be easier.
How we can refactor then? I don't have analized that yet.
what are your ideas about that?

Saludos.

Marcos Barreto

unread,
Feb 1, 2012, 1:29:25 PM2/1/12
to dorm-the-...@googlegroups.com
Daniele would like that I just change the methods of PersistentStrategy to receive just the mapping tables. But I think that adapters need a a liltle more refactory. But for while I think to follow him ideas.

My idea:

function TSession.Load(ATypeInfo: PTypeInfo; const Value: TValue): TObject;
var
  rt: TRttiType;
  _table: TMappingTable;
  _fields: TMappingFieldList;
  _idValue: TValue;
begin
  rt := FCTX.GetType(ATypeInfo);
  GetLogger.EnterLevel('Load ' + rt.ToString);
  _table := FMappingStrategy.GetMapping(rt);
  _fields := _table.Fields;
  Result := FPersistStrategy.Load(rt, _table.TableName, _fields, Value);
  if assigned(Result) then
  begin
    _idValue := GetIdValue(_table.Id, Result);
    LoadBelongsToRelation(_table, _idValue, rt, Result);
    LoadHasManyRelation(_table, _idValue, rt, Result);
    LoadHasOneRelation(_table, _idValue, rt, Result);
  end;
  DoOnAfterLoad(Result);
  GetLogger.ExitLevel('Load ' + rt.ToString);
end;

To turn this:

function TSession.Load(ATypeInfo: PTypeInfo; const Value: TValue): TObject;
var
  rt: TRttiType;
begin
  rt := FCTX.GetType(ATypeInfo);
  GetLogger.EnterLevel('Load ' + rt.ToString);
  Result := FPersistStrategy.Load(rt, Value);
  DoOnAfterLoad(Result);
  GetLogger.ExitLevel('Load ' + rt.ToString);
end;

FPersistStrategy could receive Session itself, and FMappingStrategy so FPersistStrategy could have
LoadBelongsToRelation, LoadHasManyRelation, LoadHasOneRelation and this methods could call the session.load to your relations.

With changes like this on session we can decide after load the objects with inner or left joins in future.
Other think cascade update/deletes and inserts.
I think that session have many responsabilities, but just play this thing on adapterbase too will turn it with many responsabilities
I think that we need break this way

Session ----> FPersistentStrategy -------> Driver ----> BaseAdapter and descendents (not sure yet just a idea)

Daniele Teti

unread,
Feb 1, 2012, 5:05:12 PM2/1/12
to dorm-the-...@googlegroups.com

Marcos,
I agree with the refactor in the session. Adapters will become more complex but they will be also more flexyble.

We can do this.
What is still in limbo are the drivers but we can talk about this after the session refactoring.

Bye, Daniele

--
You received this message because you are subscribed to the Google Groups "dorm, The Delphi ORM" group.
To post to this group, send email to dorm-the-...@googlegroups.com.
To unsubscribe from this group, send email to dorm-the-delphi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/dorm-the-delphi-orm?hl=en.

Marcos Barreto

unread,
Feb 1, 2012, 6:59:11 PM2/1/12
to dorm-the-...@googlegroups.com
I will try do then!
Reply all
Reply to author
Forward
0 new messages