Thanks, it worked when I put it in the .hbmxml file. I was missing the
() around the entire sql statement and I couldn't use the .get() in
ColdMVC, I had to use entityload():
var stuff = EntityLoad("Project",1,true);
writeDump("hit");writeDump(stuff.getRating());
<property type="int"
formula="(select count(
project_rating.id) from project inner join
project_rating on project_rating.project_id =
project.id inner join
[rating] on [rating].id = project_rating.rating_id where
project_rating.project_id = id)"
name="rating"/>
The above works, but it's not want I am trying to accomplish yet.
Now I am trying to use sum() in the SQL statement and its failing.
Example:
<property type="int"
http://groups.google.com/group/coldmvc/
browse_thread/thread/e292293be4f759cf
formula="(select sum(rating.[rank]) / count(
project_rating.id) from
project inner join project_rating on project_rating.project_id =
project.id inner join [rating] on [rating].id =
project_rating.rating_id where project_rating.project_id = id)"
name="rating"/>
Here's the error:
[Macromedia][SQLServer JDBC Driver][SQLServer]Invalid object name
'project0_.rating'.
Root cause :java.sql.SQLSyntaxErrorException: [Macromedia][SQLServer
JDBC Driver][SQLServer]Invalid object name 'project0_.rating'.
I am going to try to turn on query logging to figure out where
project0_ is coming from. As for not being able to use .get() in
ColdMVC I keep getting the following error:
could not execute query
The error occurred in C:\workspace\coldmvc\DAO.cfc: line 347
line 347 looks like this: var records = result.uniqueResult();
Any ideas?
On Oct 27, 8:46 pm, Tony Nelson <
tonynelso...@gmail.com> wrote:
> If you're using an .hbmxml file, you'll need to specify all of the mapping
> properties inside the file. The properties inside the .cfc are merely used
> to generate the .hbmxml files that are required by Hibernate. If you're
> using your own .hbmxml file, ColdFusion/Hibernate will ignore any additional
> property mappings you might've specified inside the .cfc and only use what
> you have defined inside the .hbmxml file.
>
> Long story short, try moving the formula definition from the .cfc to the
> .hbmxml file.
>
> -Tony
>
> On Wed, Oct 27, 2010 at 9:38 PM, Joe <
jban...@gmail.com> wrote:
> > No luck. I tried to dump my query down to get a result but I still get
> > an empty string. Here's what I got:
>
> > Project.cfc
> > property name="rating" persistent = "false" formula="select
> > Count(
pr.id) from project as p inner join project_rating as pr on
> > pr.project_id =
pr.id where pr.project_id =
p.id";
>
> > hib file
> > <property name="rating" type="string">
> > </property>
>
> > I also tried this site but it didn't work for me.
>
> >
http://www.manjukiran.net/2009/07/18/coldfusion-orm-define-computed-p...