Relating ORM components in different folders

41 views
Skip to first unread message

Drew Dulgar

unread,
Sep 4, 2015, 10:35:29 AM9/4/15
to cf-orm-dev
Am I going crazy... shouldn't this be possible?

So currently we have an infrastructure that resembles multiple "apps". Each app has it's own ORM models/components folders, however there are some cases where the ORM components need to reference information across apps. There is one application.cfc that is at the root of all apps.


I have a setup that looks similiar to the following directory structure:

/Application.cfc
/app1/cfcs/models/
/app2/cfcs/models/


In application.cfc, the following is defined:


this.mappings = {
...
"/app1Models" = "/full/path/to/app1/cfcs/models",
"/app2Models" = "/full/path/to/app2/cfcs/models",
...
}

And then the ORM config has:

this.ormSettings = {
...
cflocation = ["/app1Models", "/app2Models"],
...
}

So this works just fine as long as any of the property CFC attributes reference a component within the same folder, but if I try something where an app1 component relates to a app2 component via a cfproperty tag, it cannot find the component.

IE within app1/Model.cfc,
...cfproperty name="app2Relationsip" cfc="/app2Models/Model2"...

I tried using:
/app2Models/app2Model1
app2Models/app2Model1
/app2Models.app2Model
app2Models.app2Model

All of which yielded one form or another of CF's inability to locate the app2 model.

Thoughts? Is this just a nono with the ORM?


Brian Kotek

unread,
Sep 4, 2015, 11:40:54 AM9/4/15
to cf-or...@googlegroups.com
I'm not even sure what the "cfc" attribute is. I think what you want is type="app2Models.Model2".



--
You received this message because you are subscribed to the Google Groups "cf-orm-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cf-orm-dev+...@googlegroups.com.
To post to this group, send email to cf-or...@googlegroups.com.
Visit this group at http://groups.google.com/group/cf-orm-dev.
For more options, visit https://groups.google.com/d/optout.

Brian Kotek

unread,
Sep 4, 2015, 11:45:01 AM9/4/15
to cf-or...@googlegroups.com
Hmm, never mind. Maybe it's just been too long since I've used CF. Looks like the docs do show using "cfc" in relationships.

Jason Durham

unread,
Sep 4, 2015, 11:59:17 AM9/4/15
to cf-or...@googlegroups.com
I think Brian touched on the issue.  Shouldn't the path contain dots instead of slashes for delimiters?  Relationships across directories is definitely a common thing.  

Jason Durham

Drew Dulgar

unread,
Sep 4, 2015, 1:51:12 PM9/4/15
to cf-orm-dev, ja...@durhamcons.com
I tried just about every variation of dot notation and slash notation I could think of. While I know this is pretty common with standard CFCs, (and I have not had issues with this side of it), doing it from within a persistent component, especially relating to orm relationships, is where it is faltering.

Drew Dulgar

unread,
Sep 14, 2015, 10:10:10 AM9/14/15
to cf-orm-dev, ja...@durhamcons.com
So just an update, I still have yet to get this working completely, but something really interesting is happening here.

From the looks of it, I gave a slightly inaccurate example of how my setup is. Right now, it looks like this (with the mapping and orm cfclocation as outlined in the first post).

this.mappings = {
...
"/baseModels" = "/full/path/to/cfcs/baseModels",


"/app1Models" = "/full/path/to/app1/cfcs/models",
"/app2Models" = "/full/path/to/app2/cfcs/models",
...
}

/cfcs/baseModels/
/app1/cfcs/models/
/app2/cfcs/models/
/application.cfc


Now, as long as I don't reference components in different folders, everything works fine.

I can also create a reference from one of the app model folders to /cfcs/basemodels.
As an example, within /app1/cfcs/models/ I can set:
property name="foo" fieldtype="one-to-many" cfc="baseModels.bar";

However, I can't do it the other way around. Within /cfcs/baseModels, I can't do
property name="foo" fieldtype="many-to-one" cfc="app1Models.bar";

This ends up throwing a "cannot initialize component for relationship "foo". Can't find component".

Chip Pinkston

unread,
Oct 20, 2015, 3:55:05 AM10/20/15
to cf-orm-dev, ja...@durhamcons.com
Just a quick thought to test your mapping. What happens if you try something like:
bar = createObject('component', 'app1Models.bar');
writeDump(bar);
abort;

Reply all
Reply to author
Forward
0 new messages