|
Hi Doug, Thanks for a great new addition to
Reactor. I have already switched my application to using aliases on tables, and
it seems to work great. I still have problems with linked tables
though (refer to my mail ” Need
help with linked tables” sent on the 22.). In your mail, you mention that it’s
possible to use aliases on hasOne/hasMany in order to rename specific
relationships. In my case, I’m trying to do this on the hasOne
relationships, because they are both working on the same table. I can’t get it to work though. This
time around it complains that the routine getXYZIterator has been declared
twice in the same file. (where XYZ is the name used in the <link> tag,
which in turn is the same as the alias on the linking table object). I can provide you with an updated example
if you like, but since you have provided an example below, I’ll use that. Given that you change the linked table in
your example to the following:
<object name="tblEntryCategory" alias="EntryCategory">
<hasOne name="Entry" alias=”MyEntry”>
<relate from="entryId" to="entryId" />
</hasOne>
<hasOne name="Category" alias=”MyCategory”>
<relate from="categoryId" to="categoryId" />
</hasOne>
</object> Could you then change the relationship for
the Entry object as follows? <object name="tblEntry"
alias="Entry">
<hasMany name="MyCategory">
<link name="EntryCategory" />
</hasMany>
</object> If this should work, then the problem in
my case must be that my linking table works on the same table twice.. It would be great to hear your opinion on
this matter, and I would happily provide you with examples from my own
application if you need (the only changes from what I wrote in my previous
email is that I’ve added aliases to my tables though). Regards Tormod Boga Inbusiness AS Fra: Doug Hughes
[mailto:[EMAIL PROTECTED] Hey all, I thought I should let you know that I rolled out two
much-requested feature today: Table aliases and Field aliases. First off, this really shouldn’t break any
existing code. The framework should just work. However, the update
did, in fact, touch almost every file in reactor. I suggest that you
delete everything under the /reactor/project folder and start fresh.
There were also some changes to the custom objects, but don’t bother
recreating them, the changes only involved names. So, because this touched so much I really need people
to test this feature and report things that did work, but which no longer work. That said, here’s the rundown on the new
features: Table Aliases. Typically you’d add an
object in your reactor.xml like this: <object name="Category" /> However, what if you have a legacy table name?
IE: tbl_Cat It’d suck to have you create an instance of that
object. It’s ugly. Or, what if your tables are plural?
IE: customers. Then you’d be stuck creating a CustomersRecord,
which is obnoxious. So, now you can add an alias to that tag: <object name="tbl_Cat" alias=”Category”
/> Or <object name=”Customers”
alias=”Customer” /> Now you can use the reactorFactory to create an
instance of a Category or Customer record. The files on disk get the
aliased name too. Note: Anywhere you don’t provide an
alias, the alias is implicitly created as the item’s name. Thus,
the following example actually gets an alias of Category. This is true
across all of reactor. <object name="Category" />
Any time you create a relationship you must set the
relationship’s name as the target object’s alias. For
example, let’s say you three tables, tblEntry, tblEntryCategory and
tblCategory. tblEntryCategory hasOne of both tblEntry and
tblCategory. tblEntry and tblCategory haveMany of each over via
tblEntryCategory. If you wanted to alias these objects to get rid of your
tbl prefix your xml would look like this: <objects>
<object name="tblEntry" alias="Entry">
<hasMany name="Category">
<link name="EntryCategory" />
</hasMany>
</object>
<object name="tblEntryCategory" alias="EntryCategory">
<hasOne name="Entry">
<relate from="entryId" to="entryId" />
</hasOne>
<hasOne name="Category">
<relate from="categoryId" to="categoryId" />
</hasOne>
</object>
<object name="tblCategory" alias="Category">
<hasMany name="Entry">
<link name="EntryCategory" />
</hasMany>
</object> </objects> Why do I use the name attribute on the hasmany/hasone
tags? Because these tags also have aliases. So, I could rename a
specific relationship. IE: <object name="tblCategory"
alias="Category">
<hasMany name="Entry" alias=”Article”>
<link name="EntryCategory" />
</hasMany> </object> Field Aliases. I also introduced field
aliases. Field aliases let you rename fields in your objects. For
example, you might have a column named colIntCatId. Maybe you want this
addressed as categoryId in your application. To do this you add field
tags inside your object tags. For example: <object name="tblEntry" alias="Entry"> <field
name=”colIntCatId” alias=”categoryId” /> <hasMany
name="Category">
<link
name="EntryCategory" />
</hasMany> </object> Doing this will cause the properties in the TO use
the alias, the get/setters on your records to use the alias, it will show up in
the metadata, and your queries will return that column name. It’s
actually petty slick! Any fields you don’t define aliases for will
implicitly be given an alias the same as their name. So, please, get latest. Test this out. If
you find any issues please let me know. If something seems funny with
these features, please let me know! This is a BIG update and there are
likely to be bugs in it. Next On Tap: -
A solution to the Oracle
issues (sorry to keep you waiting Beth) -
A DB2 driver -
A Postgres driver -
Updated validation -
A real fix for mssql
default value problems. Thanks, Doug
|
- [Reactor For CF] New features: Table and Field aliases Doug Hughes
- Re: [Reactor For CF] New features: Table and Field ... Dave Shuck
- SV: [Reactor For CF] New features: Table and Field... Tormod Boga
- RE: [Reactor For CF] New features: Table and Field... Daniel Short
- Re: [Reactor For CF] New features: Table and Field ... Sean Corfield
- RE: [Reactor For CF] New features: Table and Fi... Doug Hughes
- Re: [Reactor For CF] New features: Table an... Sean Corfield
- [Reactor For CF] Cutting out Repetive setXXX(FORM.X... Daniel Short
- RE: [Reactor For CF] Cutting out Repetive setXX... Doug Hughes
- RE: SPAM-LOW: RE: [Reactor For CF] Cutting... Daniel Short
- Re: SPAM-LOW: RE: [Reactor For CF] Cut... Jared Rypka-Hauer
- RE: SPAM-LOW: Re: SPAM-LOW: RE: ... Daniel Short
- RE: SPAM-LOW: RE: [Reactor For CF... Doug Hughes

