1Rose::DB::Object::MetadUasteRaro:s:CeRo:en:ltDarBti:ib:ouOntbsejhdeicpPt:e::r:OlMneeDtToaocdMuaamtneayn:(t:3aR)teiloantionship::OneToMany(3)
2
3
4

NAME

6       Rose::DB::Object::Metadata::Relationship::OneToMany - One to many table
7       relationship metadata object.
8

SYNOPSIS

10         use Rose::DB::Object::Metadata::Relationship::OneToMany;
11
12         $rel = Rose::DB::Object::Metadata::Relationship::OneToMany->new(...);
13         $rel->make_methods(...);
14         ...
15

DESCRIPTION

17       Objects of this class store and manipulate metadata for relationships
18       in which a single row from one table refers to multiple rows in another
19       table.
20
21       This class inherits from Rose::DB::Object::Metadata::Relationship.
22       Inherited methods that are not overridden will not be documented a
23       second time here.  See the Rose::DB::Object::Metadata::Relationship
24       documentation for more information.
25

METHOD MAP

27       "count"
28           Rose::DB::Object::MakeMethods::Generic, objects_by_key, "interface
29           => 'count'" ...
30
31       "find"
32           Rose::DB::Object::MakeMethods::Generic, objects_by_key, "interface
33           => 'find'" ...
34
35       "iterator"
36           Rose::DB::Object::MakeMethods::Generic, objects_by_key, "interface
37           => 'iterator'" ...
38
39       "get_set"
40           Rose::DB::Object::MakeMethods::Generic, objects_by_key, "interface
41           => 'get_set'" ...
42
43       "get_set_now"
44           Rose::DB::Object::MakeMethods::Generic, objects_by_key, "interface
45           => 'get_set_now'" ...
46
47       "get_set_on_save"
48           Rose::DB::Object::MakeMethods::Generic, objects_by_key, "interface
49           => 'get_set_on_save'" ...
50
51       "add_now"
52           Rose::DB::Object::MakeMethods::Generic, objects_by_key, "interface
53           => 'add_now'" ...
54
55       "add_on_save"
56           Rose::DB::Object::MakeMethods::Generic, objects_by_key, "interface
57           => 'add_on_save'" ...
58
59       See the Rose::DB::Object::Metadata::Relationship documentation for an
60       explanation of this method map.
61

CLASS METHODS

63       default_auto_method_types [TYPES]
64           Get or set the default list of auto_method_types.  TYPES should be
65           a list of relationship method types.  Returns the list of default
66           relationship method types (in list context) or a reference to an
67           array of the default relationship method types (in scalar context).
68           The default list contains "find", "get_set_on_save", and
69           "add_on_save".
70

OBJECT METHODS

72       build_method_name_for_type TYPE
73           Return a method name for the relationship method type TYPE.
74
75           For the method types "get_set", "get_set_now", and
76           "get_set_on_save", the relationship's name is returned.
77
78           For the method types "add_now" and "add_on_save", the
79           relationship's name prefixed with "add_" is returned.
80
81           For the method type "find", the relationship's name prefixed with
82           "find_" is returned.
83
84           For the method type "count", the relationship's name suffixed with
85           "_count" is returned.
86
87           For the method type "iterator", the relationship's name suffixed
88           with "_iterator" is returned.
89
90           Otherwise, undef is returned.
91
92       is_singular
93           Returns false.
94
95       manager_class [CLASS]
96           Get or set the name of the Rose::DB::Object::Manager-derived class
97           used to fetch objects.  The make_methods method will use
98           Rose::DB::Object::Manager if this value is left undefined.
99
100           Note: when the name of a relationship that has "manager_args" is
101           used in a Rose::DB::Object::Manager with_objects or require_objects
102           parameter value, only the sort_by argument will be copied from
103           "manager_args" and incorporated into the query.
104
105       manager_method [METHOD]
106           Get or set the name of the manager_class class method to call when
107           fetching objects.  The make_methods method will use get_objects if
108           this value is left undefined.
109
110       manager_count_method [METHOD]
111           Get or set the name of the manager_class class method to call when
112           counting objects.  The make_methods method will use
113           get_objects_count if this value is left undefined.
114
115       manager_iterator_method [METHOD]
116           Get or set the name of the manager_class class method to call when
117           creating an iterator.  The make_methods method will use
118           get_objects_iterator if this value is left undefined.
119
120       manager_args [HASHREF]
121           Get or set a reference to a hash of name/value arguments to pass to
122           the manager_method when fetching objects.  For example, this can be
123           used to enforce a particular sort order for objects fetched via
124           this relationship.  For example:
125
126             Product->meta->add_relationship
127             (
128               code_names =>
129               {
130                 type         => 'one to many',
131                 class        => 'CodeName',
132                 column_map   => { id => 'product_id' },
133                 manager_args =>
134                 {
135                   sort_by => CodeName->meta->table . '.name',
136                 },
137               },
138             );
139
140           This would ensure that a "Product"'s "code_names()" are listed in
141           alphabetical order.  Note that the "name" column is prefixed by the
142           name of the table fronted by the "CodeName" class.  This is
143           important because several tables may have a column named "name."
144           If this relationship is used to form a JOIN in a query along with
145           one of those tables, then the "name" column will be ambiguous.
146           Adding a table name prefix disambiguates the column name.
147
148           Also note that the table name is not hard-coded.  Instead, it is
149           fetched from the Rose::DB::Object-derived class that fronts the
150           table.  This is more verbose, but is a much better choice than
151           including the literal table name when it comes to long-term
152           maintenance of the code.
153
154           See the documentation for Rose::DB::Object::Manager's get_objects
155           method for a full list of valid arguments for use with the
156           "manager_args" parameter, but remember that you can define your own
157           custom manager_class and thus can also define what kinds of
158           arguments "manager_args" will accept.
159
160       map_column LOCAL [, FOREIGN]
161           If passed a local column name LOCAL, return the corresponding
162           column name in the foreign table.  If passed both a local column
163           name LOCAL and a foreign column name FOREIGN, set the local/foreign
164           mapping and return the foreign column name.
165
166       column_map [HASH | HASHREF]
167           Get or set a reference to a hash that maps local column names to
168           foreign column names.
169
170       query_args [ARRAYREF]
171           Get or set a reference to an array of query arguments to add to the
172           query passed to the manager_method when fetching objects.
173
174       type
175           Returns "one to many".
176

AUTHOR

178       John C. Siracusa (siracusa@gmail.com)
179

LICENSE

181       Copyright (c) 2010 by John C. Siracusa.  All rights reserved.  This
182       program is free software; you can redistribute it and/or modify it
183       under the same terms as Perl itself.
184
185
186
187perl v5.30.0            Rose::DB::2O0b1j9e-c0t7:-:2M6etadata::Relationship::OneToMany(3)
Impressum