Ormexecutequery in model that points to different database

Hi,

I’m using an object that maps to different datasource. EntityLoad works
great but when I try to use ormexecutequery it doesn’t work.

My code:

1: EntityLoadByPk(“myobject”, 1);

  • 2: ORMExecuteQuery(“from myobject where id=1”);*

myobject is not mapped
org.hibernate.hql.ast.QuerySyntaxException

The Error Occurred in test.cfm: line 2

Is this a bug with the multiple datasource in orm?

Btw, myobject.cfc definition:
component persistent=“true” datasource=“myotherdb” table=“testing”

Thanks–
David Sedeño

Hi David, try

ORMExecuteQuery(“from myobject where id=1”,true,{datasource=“myotherdb”});

I don’t think this is a bug because in ACF you also have to specify
the alternative datasource when using ORMExecuteQuery().

http://help.adobe.com/en_US/ColdFusion/10.0/Developing/WSbfbbf049491c37b01e63e3d129fe0a8552-7ff1.html

JulianOn 6 May 2015 at 09:45, David Sedeño <@David_Sedeno> wrote:

I’m using an object that maps to different datasource. EntityLoad works
great but when I try to use ormexecutequery it doesn’t work.

My code:

1: EntityLoadByPk(“myobject”, 1);
2: ORMExecuteQuery(“from myobject where id=1”);

myobject is not mapped
org.hibernate.hql.ast.QuerySyntaxException

The Error Occurred in test.cfm: line 2

Is this a bug with the multiple datasource in orm?

Hi Julian,El miércoles, 6 de mayo de 2015, 12:39:06 (UTC+2), Julian Halliwell escribió:

Hi David, try

ORMExecuteQuery(“from myobject where id=1”,true,{datasource=“myotherdb”});

Thanks a lot, it’s works great! :slight_smile:


David Sedeño