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?
ormsettings.cfclocationto 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