<html>
<body>
<font size=3>Sure. It should (hopefully) be fairly easy to use, although
if you're completely new to Glorp it probably can get
interesting.<br><br>
Subclass your classes from ActiveRecord. Then use
ActiveRecordDescriptorSystem, or your own subclass of it, as the system,
and log in. If you use the main class, it'll try to use all subclasses of
ActiveRecord. If you make your own subclass you can implement
#defaultRootClass to make it just be subclasses of your own abstract
superclass (which it expects to be a subclass of ActiveRecord).<br><br>
If you've named your classes according to the generally Ruby on Rails-ish
conventions, which is to say that the Customer class corresponds to the
CUSTOMERS table (or the CUSTOMER table, it's not all that fussy), then it
should try to generate descriptors for that automatically. It'll do a
good deal better if your foreign key fields are identified as such in the
database. For parts that it doesn't get right, or at all, you can
implement the normal Glorp methods like #descriptorForMyClassName:, but
you should only have to give it the information for the mappings it
didn't get right in the first place.<br><br>
There are some simple examples in the GlorpActiveRecordTests package.
Once it's mapped, then you can do a number of things by sending messages
to the objects or their classes that would typically require you to use
the Glorp session. e.g. aClass findWhere:, anObject save, etc.<br><br>
At 12:57 PM 12/12/2007, Oleg Richards wrote:<br><br>
<blockquote type=cite class=cite cite="">Thank you Alan!<br><br>
I will look at this classes. I need a little help with ActiveRecord? Can
you<br>
show me how to use it? I understand that i should inherit all my models
from<br>
AR class, but what next. Should i execute something in workspace? And how
to<br>
attach session&nbsp; to active record? <br><br>
<br><br>
<br><br>
Alan Knight-2 wrote:<br>
&gt; <br>
&gt; Inheritance is always rather tricky against a relational database,
because<br>
&gt; the concept really isn't there, so you have to map it into some<br>
&gt; compromise, trading off space, query time, and flexibility. Glorp
supports<br>
&gt; two different strategies for this, which we call horizontal and
filtered.<br>
&gt; Filtered inheritance means all instances are stored in one bit
table, and<br>
&gt; there's a field which indicates which type this row represents. This
is<br>
&gt; efficient to query, but wastes spaces. Horizontal is where each
subclass<br>
&gt; is represented by an entirely separate table. This is more likely
if<br>
&gt; you're trying to impose an inheritance hierarchy on an existing
database,<br>
&gt; and minimizes storage, but makes querying more complex. Some kinds
of<br>
&gt; queries can be inefficient. You'd want to look at the TypeResolver
class<br>
&gt; and its subclasses. In the Glorp tests,
GlorpInheritanceDescriptorSystem<br>
&gt; has some examples.<br>
&gt; <br>
&gt; By comparison, storing integers and dictionaries is pretty easy :-)
If you<br>
&gt; want both key and value to be simple types, then you need a
table<br>
&gt; somewhere to store them. If the value is an object, you can either
have<br>
&gt; the key be part of the value's table, or in a link table.<br>
&gt; GlorpDictionaryMappingTest and GlorpEncyclopediaDescriptorSystem
have<br>
&gt; examples.<br>
&gt; <br>
&gt; Neither of those things is likely to work automatically with
the<br>
&gt; GlorpActiveRecord code, you'll likely have to write out the
mappings. But<br>
&gt; part of the point of the way GlorpActiveRecord is done is that you
can let<br>
&gt; the parts that are easy get built automatically and only have to
specify<br>
&gt; the tricky parts.<br>
&gt; <br>
&gt; <br>
&gt; <br><br>
-- <br>
View this message in context:
<a href="http://www.nabble.com/Persistence-in-VW-tp14283675p14300415.html" eudora="autourl">
http://www.nabble.com/Persistence-in-VW-tp14283675p14300415.html</a><br>
Sent from the Squeak - Seaside mailing list archive at
Nabble.com.<br><br>
_______________________________________________<br>
seaside mailing list<br>
seaside@lists.squeakfoundation.org<br>
<a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" eudora="autourl">
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a>
</font></blockquote></body>
<br>
<div>--</div>
<div>Alan Knight [|], Cincom Smalltalk Development</div>
<div>knight@acm.org</div>
<div>aknight@cincom.com</div>
<div><a href="http://www.cincom.com/smalltalk" EUDORA=AUTOURL>
http://www.cincom.com/smalltalk</a></div>
</html>