2
votes

I am looking into ORM and started off with some tutorials from a pdf that I found on adobe's site. I created a folder under wwwroot called test.

here is my application.cfc

component { 
   this.name = "artGalleryApp" ; 
   this.ormenabled = true ;
   this.datasource = "cfartgallery" ; 
} 

I have artists.cfc under wwwroot/test/model folder.

<cfcomponent persistent="yes" table="artists" entityname="giggidy">
  <cfproperty name="id" column = "artistID" generator="increment">
      <cfproperty name="firstName">
      <cfproperty name="lastName">
      <cfproperty name="address">
      <cfproperty name="city">
      <cfproperty name="state">
      <cfproperty name="postalCode">
      <cfproperty name="email">
      <cfproperty name="phone">
      <cfproperty name="fax">
      <cfproperty name="thePassword">
  </cfcomponent>

Then, I have an index.cfm with the following:

artists = EntityLoad("ARTISTS") ;
writeDump(artists) ; 

When I run this, I get :

 Mapping for component ARTISTS not found.
 Either the mapping for this component is missing or the application must be restarted to generate the mapping.

I restarted CF application server, and this error went away. Do I have to restart CF appliction server every single time I create an ORM application?

Is it better to use model.ARTISTS or some other way to specify where this component is located?

Now, the biggest question. I always wrote stored procedures, packages, etc etc(SQL Server, Oracle) whenever I needed DML statements. I never included inline queries in my CF code. I also handled logging and error handling within these procs, packages, etc. etc.

If I had to make a change to the database structure, I would simply modify things on the database side. For this reason only, what would be the benefits of using ORM? I change a table add/remove a field, I have to go through CF code to make the necessary updates. Why?

1
"what would be the benefits of using ORM?" - well you get to exchange the tedium of writing very basic code at the start of a project with the nightmare of constantly wrestling obscure and difficult-to-debug issues later on. I definitely recommend NOT using CF's built-in ORM. (I've heard cfwheel's version is better but not used it myself.) - Peter Boughton
Even though, I have stored procs on the database side? I haven't seen any examples but can you do ORM for stored procs? - CFNinja
I don't think I understand what you're asking. Do you have a specific reason/need for wanting to do ORM? If you have a working set of code - whether on CF side or DB side - I don't recommend converting it to ORM. If you're starting a new project ... well I'd still favour a competent DBA (whether using queries or stores procedures) over ORM. - Peter Boughton
Yes, this is exactly what I was asking. >> well I'd still favour a competent DBA (whether using queries or stores procedures) over ORM - CFNinja
You cannot use ORM with stored procedures, but with some DBMS, you can use them with 'writable views'. Have you tried setting the ormsettings.cfclocation to point to the directory where your ORM objects reside? Peter, why so down on ORM? If you understand the limitations of ANY ORM system it solves many more problems than it may create. Also, a solid understanding of Hibernate and HQL goes a long way. - Scott Stroz

1 Answers

3
votes

Mapping for component ARTISTS not found because: entityname="giggidy"

so use EntityLoad("giggidy")

And use ORMReload() and you don't need to restart CF.