Hi All,
Hope some one can help me before I go insane.
I have create two services and can’t get the connection between them to work All I get is an error “Association references unmapped class”
If I comment out the one-to-may property the error goes away.
This is what I have, in wirebox.cfc
map(“RcasiService”).to(“model.rcasis.RcasiService”).asSingleton();
map(“IimsmasterService”).to(“model.iimsmasters.IimsmasterService”).asSingleton();
Under model folder I have two folders “iimsmasters” and “rcasis”
In folder “iimsmasters” I have
IimsmasterService.cfc
component extends=“coldbox.system.orm.hibernate.VirtualEntityService” singleton {
public IimsmasterService function init(){
super.init(entityName=“Iimsmaster”);
return this;
}
}
and Iimsmaster.cfc
component persistent=“true” table=“IIMS_Master” {
property name=“IIMS_No” fieldtype=“id” column=“IIMS_No” generator=“assigned”;
property name=“FromTable” ormtype=“string”;
property name=“rcasis” fieldtype=“one-to-many” cfc=“model.rcasis.Rcasi” fkcolumn=“IIMS_No” lazy=“false” fetch=“join”;
public Iimsmaster function init(){
return this;
}
}
In folder “rcasis” I have
RcasiService.cfc
component extends=“coldbox.system.orm.hibernate.VirtualEntityService” singleton{
public RcasiService function init(){
super.init(entityName=“Rcasi”);
return this;
}
}
Rcasi.cfc
component persistent=“true” table=“RCASIMaster”{
property name=“IIMS_No” fieldtype=“id” column=“IIMS_No” generator=“assigned”;
property name=“RCA_ID” ormtype=“string”;
public Rcasi function init(){
return this;
}
}
Iimsmaster.hbmxml
As with any changes to ORM the Application needs to be reinit’ed or the ORM needs to be reloaded. What you appear to have done is created a new entity that hasn’t updated the DB, especially if that table doesn’t exist.
On a side note, services don’t need to be wire mapped the way your doing it, that method is usually needed for older business logic models. In other words if they are going to be singletons then just do this.
IimsmasterService.cfc
component extends=“coldbox.system.orm.hibernate.VirtualEntityService” singleton {
public IimsmasterService function init(){
super.init(entityName=“Iimsmaster”);
return this;
}
}
All of this becomes obsolete.
map(“RcasiService”).to(“model.rcasis.RcasiService”).asSingleton();
map(“IimsmasterService”).to(“model.iimsmasters.IimsmasterService”).asSingleton();
As ColdBox will do this if your store all your models in your models folder.
Hi Andrew,
The error comes when I try and do a ORMReload through the url.
Both tables exist. Note that if I comment out the one-to-many property and do a ORMReload the error goes away.
But as soon as I have this line of code the error is there.
The code except for the one-to-many property was created by Coldfusion Builder 3.
I thought it did not need to be in the wirebox.cfc but when I kept getting the error I thought I would try it.
Any advice on how to reload the ORM?
Changing the Application name works for me in development, or you could look into ColdFusion and the ORMReload()
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSfd7453be0f56bba463eeeea71230904a189-8000.html
One thing you could try is that I usually don’t use cfc paths for the CFC in a one to many, if you just put the CFC name do you get the same result?
Also any changes to entities need to have the upgrade setting for ORM in Application.cfc
Hi Andrew,
Thanks for your reply.
I tried all this and still no luck.
Then I thought I would remove the code from Coldbox and just use CF and see how I went.
I put all the code in the same folder and it worked straight away.
So I went back to the Coldbox code and moved the model cfc’s into the model folder and it worked.
so my question now is. Do I need to do something else so that sub folders in the model folder are recognised.
Or was the problem because the folder name was the same as the cfc?
The fact it was in a folder inside the models, yeah that will be an issue as WireBox (I think this is right) well only scan the root of the folders. I am sure I have seen that discussed a few times in here.
Brad I am sure will definitely know, so maybe wait for him to pipe in. The name of the CFC should not matter, but it maybe a problem with wirebox, again Brad should know the answer to that.
If you have /model/foo.bar then you get it like getModel( ‘foo’ )
If you have /model/foo/bar.cfc then you get it like getModel( ‘foo.bar’ )
The default scan location (or model convention if you will) is /model and are expected to specify the package just like handlers, layouts, or views.
Everything above is overridden though if you do map().to(). In that case, you call it whatever you named it in the mapping.
Everything is also overridden if you do mapDirectory( ‘model’ ). getModel( ‘foo’ ) and getModel( ‘bar’ ) will both work as it recursively scans the entire model folder and maps them all by their CFC name.
Read more here:
https://github.com/ColdBox/cbox-refcards/raw/master/WireBox/WireBox-Refcard.pdf
Thanks!
~Brad
ColdBox Platform Evangelist
Ortus Solutions, Corp
E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com
Hi,
Thanks for the replies to both of you.
I have it working now, so I will leave it as it is and do some more reading for later.
Thanks again.
Brad,
Would that also apply to property injection? I know if it was by name/alias/dsl it would not be, but the question is would the path you describe also apply to property injection or is that an area it will not work? Never done it this way, curious as it was not mentioned.
Yes, injected properties, setter injections, and constructor args all follow the same algorithm for locating mappings as an explicit getModel() call.
Thanks!
~Brad
ColdBox Platform Evangelist
Ortus Solutions, Corp
E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com
Cheers Brad, thought it would but wasn’t sure.