Skip to content

Commit e7f58ff

Browse files
committed
removed TRttiExplorer - every information about entity mapping is in TEntityData
1 parent 7b22841 commit e7f58ff

38 files changed

+265
-662
lines changed

Marshmallow/Test/ORMTests.DelphiXE.dproj

-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@
104104
<DCCReference Include="..\..\Source\Persistence\Mapping\Spring.Persistence.Mapping.CodeGenerator.pas"/>
105105
<DCCReference Include="..\..\Source\Persistence\Mapping\Spring.Persistence.Mapping.CodeGenerator.Abstract.pas"/>
106106
<DCCReference Include="..\..\Source\Persistence\Mapping\Spring.Persistence.Mapping.CodeGenerator.DB.pas"/>
107-
<DCCReference Include="..\..\Source\Persistence\Mapping\Spring.Persistence.Mapping.RttiExplorer.pas"/>
108107
<DCCReference Include="..\..\Source\Persistence\ObjectDataset\Spring.Persistence.ObjectDataset.pas"/>
109108
<DCCReference Include="..\..\Source\Persistence\ObjectDataset\Spring.Persistence.ObjectDataset.Abstract.pas"/>
110109
<DCCReference Include="..\..\Source\Persistence\ObjectDataset\Spring.Persistence.ObjectDataset.ActiveX.pas"/>
@@ -152,7 +151,6 @@
152151
<DCCReference Include="TestCoreEntityMap.pas"/>
153152
<DCCReference Include="TestCoreUtils.pas"/>
154153
<DCCReference Include="TestDatabaseManager.pas"/>
155-
<DCCReference Include="TestMapping.RttiExplorer.pas"/>
156154
<DCCReference Include="TestObjectDataset.pas"/>
157155
<DCCReference Include="TestPersistence.pas"/>
158156
<DCCReference Include="TestSession.pas"/>

Marshmallow/Test/ORMTests.DelphiXE5.dproj

-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@
111111
<DCCReference Include="..\..\Source\Persistence\Mapping\Spring.Persistence.Mapping.CodeGenerator.pas"/>
112112
<DCCReference Include="..\..\Source\Persistence\Mapping\Spring.Persistence.Mapping.CodeGenerator.Abstract.pas"/>
113113
<DCCReference Include="..\..\Source\Persistence\Mapping\Spring.Persistence.Mapping.CodeGenerator.DB.pas"/>
114-
<DCCReference Include="..\..\Source\Persistence\Mapping\Spring.Persistence.Mapping.RttiExplorer.pas"/>
115114
<DCCReference Include="..\..\Source\Persistence\ObjectDataset\Spring.Persistence.ObjectDataset.pas"/>
116115
<DCCReference Include="..\..\Source\Persistence\ObjectDataset\Spring.Persistence.ObjectDataset.Abstract.pas"/>
117116
<DCCReference Include="..\..\Source\Persistence\ObjectDataset\Spring.Persistence.ObjectDataset.ActiveX.pas"/>
@@ -160,7 +159,6 @@
160159
<DCCReference Include="TestCoreUtils.pas"/>
161160
<DCCReference Include="TestDatabaseManager.pas"/>
162161
<DCCReference Include="TestFireDACAdapter.pas"/>
163-
<DCCReference Include="TestMapping.RttiExplorer.pas"/>
164162
<DCCReference Include="TestObjectDataset.pas"/>
165163
<DCCReference Include="TestPersistence.pas"/>
166164
<DCCReference Include="TestSession.pas"/>

Marshmallow/Test/ORMTests.DelphiXE6.dproj

-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@
111111
<DCCReference Include="..\..\Source\Persistence\Mapping\Spring.Persistence.Mapping.CodeGenerator.pas"/>
112112
<DCCReference Include="..\..\Source\Persistence\Mapping\Spring.Persistence.Mapping.CodeGenerator.Abstract.pas"/>
113113
<DCCReference Include="..\..\Source\Persistence\Mapping\Spring.Persistence.Mapping.CodeGenerator.DB.pas"/>
114-
<DCCReference Include="..\..\Source\Persistence\Mapping\Spring.Persistence.Mapping.RttiExplorer.pas"/>
115114
<DCCReference Include="..\..\Source\Persistence\ObjectDataset\Spring.Persistence.ObjectDataset.pas"/>
116115
<DCCReference Include="..\..\Source\Persistence\ObjectDataset\Spring.Persistence.ObjectDataset.Abstract.pas"/>
117116
<DCCReference Include="..\..\Source\Persistence\ObjectDataset\Spring.Persistence.ObjectDataset.ActiveX.pas"/>
@@ -160,7 +159,6 @@
160159
<DCCReference Include="TestCoreUtils.pas"/>
161160
<DCCReference Include="TestDatabaseManager.pas"/>
162161
<DCCReference Include="TestFireDACAdapter.pas"/>
163-
<DCCReference Include="TestMapping.RttiExplorer.pas"/>
164162
<DCCReference Include="TestObjectDataset.pas"/>
165163
<DCCReference Include="TestPersistence.pas"/>
166164
<DCCReference Include="TestSession.pas"/>

Marshmallow/Test/ORMTests.DelphiXE7.dproj

-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@
110110
<DCCReference Include="..\..\Source\Persistence\Mapping\Spring.Persistence.Mapping.CodeGenerator.pas"/>
111111
<DCCReference Include="..\..\Source\Persistence\Mapping\Spring.Persistence.Mapping.CodeGenerator.Abstract.pas"/>
112112
<DCCReference Include="..\..\Source\Persistence\Mapping\Spring.Persistence.Mapping.CodeGenerator.DB.pas"/>
113-
<DCCReference Include="..\..\Source\Persistence\Mapping\Spring.Persistence.Mapping.RttiExplorer.pas"/>
114113
<DCCReference Include="..\..\Source\Persistence\ObjectDataset\Spring.Persistence.ObjectDataset.pas"/>
115114
<DCCReference Include="..\..\Source\Persistence\ObjectDataset\Spring.Persistence.ObjectDataset.Abstract.pas"/>
116115
<DCCReference Include="..\..\Source\Persistence\ObjectDataset\Spring.Persistence.ObjectDataset.ActiveX.pas"/>
@@ -159,7 +158,6 @@
159158
<DCCReference Include="TestCoreUtils.pas"/>
160159
<DCCReference Include="TestDatabaseManager.pas"/>
161160
<DCCReference Include="TestFireDACAdapter.pas"/>
162-
<DCCReference Include="TestMapping.RttiExplorer.pas"/>
163161
<DCCReference Include="TestObjectDataset.pas"/>
164162
<DCCReference Include="TestPersistence.pas"/>
165163
<DCCReference Include="TestSession.pas"/>

Marshmallow/Test/ORMTests.DelphiXE8.dproj

-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@
110110
<DCCReference Include="..\..\Source\Persistence\Mapping\Spring.Persistence.Mapping.CodeGenerator.pas"/>
111111
<DCCReference Include="..\..\Source\Persistence\Mapping\Spring.Persistence.Mapping.CodeGenerator.Abstract.pas"/>
112112
<DCCReference Include="..\..\Source\Persistence\Mapping\Spring.Persistence.Mapping.CodeGenerator.DB.pas"/>
113-
<DCCReference Include="..\..\Source\Persistence\Mapping\Spring.Persistence.Mapping.RttiExplorer.pas"/>
114113
<DCCReference Include="..\..\Source\Persistence\ObjectDataset\Spring.Persistence.ObjectDataset.pas"/>
115114
<DCCReference Include="..\..\Source\Persistence\ObjectDataset\Spring.Persistence.ObjectDataset.Abstract.pas"/>
116115
<DCCReference Include="..\..\Source\Persistence\ObjectDataset\Spring.Persistence.ObjectDataset.ActiveX.pas"/>
@@ -159,7 +158,6 @@
159158
<DCCReference Include="TestCoreUtils.pas"/>
160159
<DCCReference Include="TestDatabaseManager.pas"/>
161160
<DCCReference Include="TestFireDACAdapter.pas"/>
162-
<DCCReference Include="TestMapping.RttiExplorer.pas"/>
163161
<DCCReference Include="TestObjectDataset.pas"/>
164162
<DCCReference Include="TestPersistence.pas"/>
165163
<DCCReference Include="TestSession.pas"/>

Marshmallow/Test/ORMTests.dpr

-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ uses
6363
Spring.Persistence.Mapping.CodeGenerator in '..\..\Source\Persistence\Mapping\Spring.Persistence.Mapping.CodeGenerator.pas',
6464
Spring.Persistence.Mapping.CodeGenerator.Abstract in '..\..\Source\Persistence\Mapping\Spring.Persistence.Mapping.CodeGenerator.Abstract.pas',
6565
Spring.Persistence.Mapping.CodeGenerator.DB in '..\..\Source\Persistence\Mapping\Spring.Persistence.Mapping.CodeGenerator.DB.pas',
66-
Spring.Persistence.Mapping.RttiExplorer in '..\..\Source\Persistence\Mapping\Spring.Persistence.Mapping.RttiExplorer.pas',
6766
Spring.Persistence.ObjectDataset in '..\..\Source\Persistence\ObjectDataset\Spring.Persistence.ObjectDataset.pas',
6867
Spring.Persistence.ObjectDataset.Abstract in '..\..\Source\Persistence\ObjectDataset\Spring.Persistence.ObjectDataset.Abstract.pas',
6968
Spring.Persistence.ObjectDataset.ActiveX in '..\..\Source\Persistence\ObjectDataset\Spring.Persistence.ObjectDataset.ActiveX.pas',
@@ -114,7 +113,6 @@ uses
114113
{$IFDEF DELPHIXE5_UP}
115114
TestFireDACAdapter in 'TestFireDACAdapter.pas',
116115
{$ENDIF}
117-
TestMapping.RttiExplorer in 'TestMapping.RttiExplorer.pas',
118116
TestObjectDataset in 'TestObjectDataset.pas',
119117
TestPersistence in 'TestPersistence.pas',
120118
TestSession in 'TestSession.pas',

Marshmallow/Test/TestAnsiSQLGenerator.pas

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ implementation
3737
uses
3838
TestEntities,
3939
Spring.TestUtils,
40-
Spring.Persistence.Mapping.Attributes,
41-
Spring.Persistence.Mapping.RttiExplorer;
40+
Spring.Persistence.Core.EntityCache,
41+
Spring.Persistence.Mapping.Attributes;
4242

4343
function CreateTestTable: TSQLTable;
4444
begin
@@ -321,7 +321,7 @@ procedure TAnsiSQLGeneratorTest.TestGenerateCreateTable;
321321
LTable := CreateTestTable;
322322
LCommand := TCreateTableCommand.Create(LTable);
323323
try
324-
LCols := TRttiExplorer.GetColumns(TCustomer);
324+
LCols := TEntityCache.Get(TCustomer).Columns;
325325
LCommand.SetCommandFieldsFromColumns(LCols);
326326

327327
ReturnValue := FAnsiSQLGenerator.GenerateCreateTable(LCommand);
@@ -342,7 +342,7 @@ procedure TAnsiSQLGeneratorTest.TestGenerateCreateFK;
342342
LTable := CreateTestTable;
343343
LCommand := TCreateForeignKeyCommand.Create(LTable);
344344
try
345-
LCols := TRttiExplorer.GetColumns(TCustomer);
345+
LCols := TEntityCache.Get(TCustomer).Columns;
346346
LCommand.SetCommandFieldsFromColumns(LCols);
347347
LCommand.ForeignKeys.Add(
348348
TSQLForeignKeyField.Create(

Marshmallow/Test/TestCoreEntityMap.pas

+29-52
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,22 @@ TEntityMapTest = class(TTestCase)
3333
implementation
3434

3535
uses
36-
SysUtils
37-
,Spring.Persistence.Mapping.Attributes
38-
,Spring.Persistence.Mapping.RttiExplorer
39-
,Spring.Persistence.Core.EntityCache
40-
,Spring.Persistence.Core.EntityWrapper
41-
,Spring.Persistence.Core.Interfaces
42-
,Diagnostics
43-
,Generics.Collections
44-
;
36+
Diagnostics,
37+
Generics.Collections,
38+
SysUtils,
39+
Spring.Persistence.Core.EntityCache,
40+
Spring.Persistence.Mapping.Attributes;
4541

4642
type
43+
[Table]
4744
TTest1 = class
4845
public
4946
[Column('TESTID', [cpRequired, cpPrimaryKey, cpNotNull], 0, 0, 0, 'Primary Key')]
5047
[AutoGenerated]
5148
FId: Integer;
5249
end;
5350

51+
[Table]
5452
TTest2 = class
5553
public
5654
[Column('TESTID', [cpRequired, cpPrimaryKey, cpNotNull], 0, 0, 0, 'Primary Key')]
@@ -89,7 +87,6 @@ procedure TEntityMapTest.TestIsMapped;
8987
ReturnValue: Boolean;
9088
AObject, LClone: TCustomer;
9189
LCompany, LClonedCompany: TCompany;
92-
entityWrapper: IEntityWrapper;
9390
begin
9491
AObject := CreateCustomer;
9592
LCompany := CreateCompany;
@@ -98,15 +95,13 @@ procedure TEntityMapTest.TestIsMapped;
9895
try
9996
ReturnValue := FEntityMap.IsMapped(AObject);
10097
CheckFalse(ReturnValue);
101-
entityWrapper := TEntityWrapper.Create(LClone);
102-
FEntityMap.AddOrReplace(entityWrapper);
98+
FEntityMap.AddOrReplace(LClone);
10399
ReturnValue := FEntityMap.IsMapped(AObject);
104100
CheckTrue(ReturnValue);
105101

106102
ReturnValue := FEntityMap.IsMapped(LCompany);
107103
CheckFalse(ReturnValue);
108-
entityWrapper := TEntityWrapper.Create(LClonedCompany);
109-
FEntityMap.AddOrReplace(entityWrapper);
104+
FEntityMap.AddOrReplace(LClonedCompany);
110105

111106
ReturnValue := FEntityMap.IsMapped(LCompany);
112107
CheckTrue(ReturnValue);
@@ -121,13 +116,11 @@ procedure TEntityMapTest.TestIsMapped;
121116
procedure TEntityMapTest.TestAdd;
122117
var
123118
LCustomer: TCustomer;
124-
entityWrapper: IEntityWrapper;
125119
begin
126120
LCustomer := CreateCustomer;
127121
try
128122
CheckFalse(FEntityMap.IsMapped(LCustomer));
129-
entityWrapper := TEntityWrapper.Create(LCustomer);
130-
FEntityMap.AddOrReplace(entityWrapper);
123+
FEntityMap.AddOrReplace(LCustomer);
131124
CheckTrue(FEntityMap.IsMapped(LCustomer));
132125
finally
133126
LCustomer.Free;
@@ -137,15 +130,13 @@ procedure TEntityMapTest.TestAdd;
137130
procedure TEntityMapTest.TestAddOrReplace;
138131
var
139132
LCustomer: TCustomer;
140-
entityWrapper: IEntityWrapper;
141133
begin
142134
LCustomer := CreateCustomer;
143135
try
144136
CheckFalse(FEntityMap.IsMapped(LCustomer));
145-
entityWrapper := TEntityWrapper.Create(LCustomer);
146-
FEntityMap.AddOrReplace(entityWrapper);
137+
FEntityMap.AddOrReplace(LCustomer);
147138
CheckTrue(FEntityMap.IsMapped(LCustomer));
148-
FEntityMap.AddOrReplace(entityWrapper);
139+
FEntityMap.AddOrReplace(LCustomer);
149140
CheckTrue(FEntityMap.IsMapped(LCustomer));
150141
finally
151142
LCustomer.Free;
@@ -163,7 +154,6 @@ procedure TEntityMapTest.TestAddOrReplace_Clone_Speed;
163154
LObjectDict: IDictionary<string,TObject>;
164155
LNativeDict: TDictionary<string,TValue>;
165156
LValue: TValue;
166-
entityWrapper: IEntityWrapper;
167157
begin
168158
iCount := 50000;
169159
LCustomers := TCollections.CreateObjectList<TCustomer>(True);
@@ -174,24 +164,21 @@ procedure TEntityMapTest.TestAddOrReplace_Clone_Speed;
174164

175165
sw := TStopwatch.StartNew;
176166
for i := 0 to iCount - 1 do
177-
begin
178-
entityWrapper := TEntityWrapper.Create(LCustomers[i]);
179-
FEntityMap.AddOrReplace(entityWrapper);
180-
end;
167+
FEntityMap.AddOrReplace(LCustomers[i]);
181168
sw.Stop;
182169

183170
Status(Format('%D items in %D ms', [iCount, sw.ElapsedMilliseconds]));
184171

185-
//previous implementation
186-
LObjectDict := TCollections.CreateDictionary<string, TObject>([doOwnsValues]);
187-
sw := TStopwatch.StartNew;
188-
for i := 0 to iCount - 1 do
189-
begin
190-
LObjectDict.AddOrSetValue('some random key', TRttiExplorer.Clone(LCustomers[i]));
191-
end;
192-
sw.Stop;
193-
194-
Status(Format('Previous implementation: %D items in %D ms', [iCount, sw.ElapsedMilliseconds]));
172+
// //previous implementation
173+
// LObjectDict := TCollections.CreateDictionary<string, TObject>([doOwnsValues]);
174+
// sw := TStopwatch.StartNew;
175+
// for i := 0 to iCount - 1 do
176+
// begin
177+
// LObjectDict.AddOrSetValue('some random key', TRttiExplorer.Clone(LCustomers[i]));
178+
// end;
179+
// sw.Stop;
180+
//
181+
// Status(Format('Previous implementation: %D items in %D ms', [iCount, sw.ElapsedMilliseconds]));
195182

196183
iCount := iCount * 10;
197184
sw := TStopwatch.StartNew;
@@ -220,7 +207,6 @@ procedure TEntityMapTest.TestHash;
220207
var
221208
LTest1: TTest1;
222209
LTest2: TTest2;
223-
entityWrapper: IEntityWrapper;
224210
begin
225211
LTest1 := TTest1.Create;
226212
LTest2 := TTest2.Create;
@@ -229,8 +215,7 @@ procedure TEntityMapTest.TestHash;
229215

230216
CheckFalse(FEntityMap.IsMapped(LTest1));
231217
CheckFalse(FEntityMap.IsMapped(LTest2));
232-
entityWrapper := TEntityWrapper.Create(LTest1);
233-
FEntityMap.AddOrReplace(entityWrapper);
218+
FEntityMap.AddOrReplace(LTest1);
234219
CheckTrue(FEntityMap.IsMapped(LTest1));
235220
CheckFalse(FEntityMap.IsMapped(LTest2));
236221
finally
@@ -242,12 +227,10 @@ procedure TEntityMapTest.TestHash;
242227
procedure TEntityMapTest.TestRemove;
243228
var
244229
LCustomer: TCustomer;
245-
entityWrapper: IEntityWrapper;
246230
begin
247231
LCustomer := CreateCustomer;
248232
try
249-
entityWrapper := TEntityWrapper.Create(LCustomer);
250-
FEntityMap.AddOrReplace(entityWrapper);
233+
FEntityMap.AddOrReplace(LCustomer);
251234
CheckTrue(FEntityMap.IsMapped(LCustomer));
252235
FEntityMap.Remove(LCustomer);
253236
CheckFalse(FEntityMap.IsMapped(LCustomer));
@@ -260,11 +243,9 @@ procedure TEntityMapTest.When_Changed_One_Property_GetChangedMembers_Returns_It;
260243
var
261244
LCustomer: TCustomer;
262245
LChangedColumns: IList<ColumnAttribute>;
263-
entityWrapper: IEntityWrapper;
264246
begin
265247
LCustomer := CreateCustomer;
266-
entityWrapper := TEntityWrapper.Create(LCustomer);
267-
FEntityMap.AddOrReplace(entityWrapper);
248+
FEntityMap.AddOrReplace(LCustomer);
268249
LCustomer.Name := 'Changed';
269250
LChangedColumns := FEntityMap.GetChangedMembers(LCustomer, TEntityCache.Get(LCustomer.ClassType));
270251
CheckEquals(1, LChangedColumns.Count);
@@ -275,14 +256,12 @@ procedure TEntityMapTest.When_Changed_One_Property_GetChangedMembers_Returns_It;
275256
procedure TEntityMapTest.When_Replaced_Entity_No_MemoryLeaks;
276257
var
277258
company: TCompany;
278-
entityWrapper: IEntityWrapper;
279259
begin
280260
company := TCompany.Create;
281261
try
282-
entityWrapper := TEntityWrapper.Create(company);
283-
FEntityMap.AddOrReplace(entityWrapper);
262+
FEntityMap.AddOrReplace(company);
284263
company.Logo.LoadFromFile(PictureFilename);
285-
FEntityMap.AddOrReplace(entityWrapper);
264+
FEntityMap.AddOrReplace(company);
286265
finally
287266
company.Free;
288267
end;
@@ -293,12 +272,10 @@ procedure TEntityMapTest.When_Replaced_Entity_No_MemoryLeaks;
293272
procedure TEntityMapTest.TestClear;
294273
var
295274
LCustomer: TCustomer;
296-
entityWrapper: IEntityWrapper;
297275
begin
298276
LCustomer := CreateCustomer;
299277
try
300-
entityWrapper := TEntityWrapper.Create(LCustomer);
301-
FEntityMap.AddOrReplace(entityWrapper);
278+
FEntityMap.AddOrReplace(LCustomer);
302279
CheckTrue(FEntityMap.IsMapped(LCustomer));
303280
FEntityMap.Clear;
304281
CheckFalse(FEntityMap.IsMapped(LCustomer));

0 commit comments

Comments
 (0)