|
Loading...
|
mach-ii-for-coldfusion@googlegroups.com
[Prev] Thread [Next] | [Prev] Date [Next]
Re: [Mach-II] CF 9 ORM & Mach-II Brian Klaas Wed Apr 04 08:02:30 2012
I'm no expert in ORM, but yes, it would handle the "beans are dumb
structures, DAOs do CRUD and Gateways handle queries/searches" approach
that often results in the 5:1 mapping of an object in a system to CFCs.
I'd suggest continuing having your listeners interact with your service
layer (listeners should be fairly thin, and specific to events within the
Mach-II framework) and then let your service layer handle the real business
logic and do any kind of orchestration between components. You could have
an "ORM Manager" component to handle the ORM-specific work, but then have a
"CFC Gateway" component that does all the non-ORM interfacing to your
database. There's nothing wrong with separation of concerns between
components and keeping them cohesive by putting ORM-specific functions in
one and more traditional SQL-oriented functions in another.
brian
On Wednesday, April 4, 2012 10:08:28 AM UTC-4, Eric Cobb wrote:
>
> Nevermind, I finally figured it out. Apparently trying to leave out
> columns and letting the database defaults do their thing doesn't work with
> ORM.
>
> But, I do have another semi-related question that I'd like to get opinions
> on. What's the best way to handle the relationship between listeners,
> service layers, and the ORM layer? I currently just have my listeners
> interacting with my service layer, and the service layer works with the ORM
> layer. That seems pretty straight forward, but I wonder about things that
> I may not want to use ORM for (complex joins, call stored procs, etc...).
> Would I just put those calls in the service layer, or have another layer
> somewhere to handle that.
>
> Also, before starting with ORM I was starting to use bean, gateway, and
> DAO CFCs. Is there a benefit to going that route with ORM? It seems like
> using ORM kind of handles some of that functionality for you.
>
>
>
> ------------------------------
> *From*: "Eric Cobb" <[EMAIL PROTECTED]>
> *Sent*: Wednesday, April 04, 2012 8:05 AM
> *To*: [EMAIL PROTECTED]
> *Subject*: [Mach-II] CF 9 ORM & Mach-II
>
> I'm finally getting a chance to play with CF 9's ORM, and I'm having a
> problem getting it to work in my Mach-II app. My example is pretty simple,
> so I'm hoping that there's just something that I don't have configured
> correctly and someone here can offer me some pointers. All I'm trying to
> do is insert a Name, Email, and Password from a form into an already
> created DB table.
>
> Here is what I have so far:
>
> *userListener.cfc*
>
> <cffunction name="saveUser" output="false" access="public"
> returntype="void" hint="I create/update a user's information">
> <cfargument name="event" type="MachII.framework.Event"
> required="true" />
> <cfset getuserService().save(arguments.event.getArgs()) />
> </cffunction>
>
>
> *userService.cfc*
>
> <cffunction name="save" access="public" output="false" returntype="void">
> <cfargument name="userInfo" type="struct" required="true">
> <cftry>
> <cfset var objUser = EntityNew("user")>
> <cfset objUser.setid(createuuid())>
> <cfset objUser.setemail(arguments.userInfo.email)>
> <cfset objUser.setpassword(arguments.userInfo.password)>
> <cfset objUser.setname(arguments.userInfo.name)>
>
> <cfset EntitySave(objUser,true)>
> <cfabort>
>
> <cfcatch type="any">
> <cfdump var="#cfcatch#">
> <cfabort>
> </cfcatch>
> </cftry>
> </cffunction>
>
>
> Pretty straight forward, right? For whatever reason, I can't get
> EntitySave() to work. I don't get an error, the browser just spins and
> spins until CF eventually times out. If I put a dump just before
> EntitySave() all of the data is there and correct. my ORM CFC is pretty
> basic, too:
>
>
> *user.cfc
> *
> <cfcomponent displayname="user" output="false" persistent="true"
> table="user">
> <cfproperty name="id" type="uuid" fieldtype="id" generator="uuid">
> <cfproperty name="email">
> <cfproperty name="password">
> <cfproperty name="name">
> </cfcomponent>
>
> I'm not sure if it matters, but here are the settings from my
> Application.cfc file:
>
> <cfset this.ormenabled = "true">
> <cfset this.datasource = "myDsn">
> <cfset this.ormsettings = {cfclocation="model/orm",dialect="MySQL"}>
>
>
> So, does anyone have any idea as to what could be going on? Am I missing
> some settings or code somewhere? Since I'm not getting any type of error,
> and this is my first time fooling with ORM, I'm kinda at a loss as to what
> to look for.
>
>
> Thanks,
>
> Eric Cobb
> http://www.cfgears.com
>
> --
> To post to this group, send email to
> [EMAIL PROTECTED]
> For more options and to unsubscribe, visit this group at
> http://groups.google.com/group/mach-ii-for-coldfusion?hl=en
>
> SVN: http://svn.mach-ii.com/machii/
> Wiki / Documentation / Tickets: http://trac.mach-ii.com/machii/
>
--
To post to this group, send email to [EMAIL PROTECTED]
For more options and to unsubscribe, visit this group at
http://groups.google.com/group/mach-ii-for-coldfusion?hl=en
SVN: http://svn.mach-ii.com/machii/
Wiki / Documentation / Tickets: http://trac.mach-ii.com/machii/
- [Mach-II] CF 9 ORM & Mach-II Eric Cobb 2012/04/04
- re: [Mach-II] CF 9 ORM & Mach-II Eric Cobb 2012/04/04
- Re: [Mach-II] CF 9 ORM & Mach-II Sumit Verma 2012/04/04
- Re: [Mach-II] CF 9 ORM & Mach-II Brian Klaas 2012/04/04 <=