Mercurial > pub > Impl
comparison Lib/IMPL/ORM.pm @ 0:03e58a454b20
Создан репозитарий
author | Sergey |
---|---|
date | Tue, 14 Jul 2009 12:54:37 +0400 (2009-07-14) |
parents | |
children | 16ada169ca75 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:03e58a454b20 |
---|---|
1 package IMPL::ORM; | |
2 use strict; | |
3 use warnings; | |
4 | |
5 use base qw(IMPL::Object); | |
6 use IMPL::Class::Property; | |
7 use Scalar::Util qw(weaken refaddr); | |
8 | |
9 use IMPL::Exception; | |
10 | |
11 our $Depth = 1; # ��������� ������ + 1 ������� ����� | |
12 our $UseProxy = 1; | |
13 | |
14 BEGIN { | |
15 private property _ObjectCache => prop_all; | |
16 private property _MapInstances => prop_all; | |
17 private property _WorkUnit => prop_all; | |
18 public property Schema => prop_all; | |
19 } | |
20 | |
21 sub ObjectInfoById { | |
22 my ($this,$oid) = @_; | |
23 | |
24 return $this->_ObjectCache->{$oid}; | |
25 } | |
26 | |
27 sub ObjectInfo { | |
28 my ($this,$inst) = @_; | |
29 | |
30 die new IMPL::InvalidOperationException("This method can be used only for a reference") unless ref $inst; | |
31 | |
32 return $this->_MapInstances->{refaddr $inst}; | |
33 } | |
34 | |
35 | |
36 1; | |
37 __END__ | |
38 =pod | |
39 =head1 SYNOPSIS | |
40 | |
41 use IMPL::ORM::Sql; | |
42 | |
43 my $DB = new IMPL::ORM::Sql("connection string"); | |
44 | |
45 local $IMPL::ORM::Depth = 1; # load childs only, no more | |
46 | |
47 my $artist = $DB->Lookup( Artist => { name => 'Beatles' } ); | |
48 | |
49 my $order = new Order(); | |
50 $order->AddItem($_) foreach $artist->Albums->List; | |
51 | |
52 $DB->Save($order); | |
53 | |
54 my $label = $artist->Albums->Index(0)->Label; | |
55 | |
56 $DB->Populate($label); #load $label | |
57 | |
58 =head1 DESCRIPTION | |
59 =head2 MEMBERS | |
60 =level 4 | |
61 =back | |
62 =head2 Variables | |
63 =head2 INTERNALS | |
64 =head3 Object Representation | |
65 | |
66 ������ ����� ������������ � �������� ������ �������������� � ���� ������ | |
67 ���������, ������ �� ������� ������������ ��������� �������� ������. | |
68 | |
69 Foo entityFoo | |
70 Bar entityBar | |
71 Baz entityBaz | |
72 | |
73 ��� ���������� ����������� ������� ������� � ��������������� ��������� ��������� | |
74 ��� ���� - ���� ��� ���������� ������������ �������� ��������, ������ - ��� | |
75 ������� ������������ ��������. | |
76 | |
77 Foo | |
78 public virtual property Name => prop_all, {Type => String}; | |
79 | |
80 entityFoo | |
81 string m_Name - ����������� �������� | |
82 string v_Name - ���������� �������� | |
83 | |
84 ������ ����������� ������ � ���� ����� ����������� �������������. | |
85 ����� ������� �������������� �� �����, �� ��� ��� ���� ��� �� ����� ���������. | |
86 | |
87 =head3 Object Cache | |
88 | |
89 ��� ����� ��������, ������� ������������ � ��������� ������ ������������ ��� | |
90 ��������. ���� �������� ���������� �� ���� �������, � ����� ����� ����������� | |
91 �������. | |
92 | |
93 ObjectInfo => { | |
94 instance => weak ref | |
95 _id => data source dependent id | |
96 state => {persistent|null|new|deleted} | |
97 work_unit => ref to the work unit where object is acting | |
98 } | |
99 | |
100 ������ ��������� �������� ����� ��� ������� ObjectInfoById � ObjectInfo | |
101 | |
102 =head3 Type mapping | |
103 | |
104 �������� ������ ����� � ���� ����� ������, ������� ���������� ����� �����, | |
105 �������� � ������ ���������. ���� ��������� ����� ����������� �����: | |
106 | |
107 =level 4 | |
108 | |
109 =item 1 | |
110 | |
111 ����������� �������, ����� ����� �������������� � ��� ������ ������� | |
112 | |
113 =item | |
114 | |
115 ����������� ������� � ���� �������� (������� ������, ������ � �.�.) | |
116 | |
117 =item | |
118 | |
119 ������, ������� �� ������ �������� � ���������� ������, ����� ��� ���������. | |
120 | |
121 =back | |
122 | |
123 =cut |