Object not an instance of declaring class

0

I am getting the error: Run query error: object is not an instance of declaring class when a test a query with a parameter.

The query below works when I replace the parameter saccId with a number e.g 4. But it does not work when I use the parameter saccId

Select mlt.mltpId As mltpId,mlt.shortName as shortName FROM MailingListType as mlt
join mlt.serviceChannelses as sc
join sc.mobi4dServices as ms
join ms.subscriberAccountServiceses as sas
where sas.subscriberAccount=:saccId
and sas.mobi4dServices=1
order by mlt.mltpId

When I test the query by typing 4 in the test value field, I get the error "Run query error: object is not an instance of declaring class". When I check the list box I still get the error.

Any help?

mkantor's picture

If this works: SELECT

If this works:

SELECT comp.company FROM Customer c ,Company comp where comp.company = c.customer and c.company = 'ABC Company' group by comp.company order by c.customer

And this fails even when your input (try using the test field in the query editor) is ABC Company

SELECT comp.company FROM Customer c ,Company comp where comp.company = c.customer and c.company = :myinput group by comp.company order by c.customer

Then I can confirm something is very wrong and I have absolutely no idea what. On the other hand, if putting in the test value works within the query editor but not in your running project, then there's probably a problem with how your input is delivered to the ServiceVariable.

Michael Kantor
SMTS; WaveMaker/SpringSource/VMware

yes MK, thats exactly what

yes MK, thats exactly what I'm saying.
c.company = 'ABC Company' works
c.company = :myco (where :myco is string, test value of anything) results in "object not an instance of declaring class while trying to run in studio"

has me baffled, thanks

help with hql that throws "object not an instance..."

I have a query that "Works" if I put in a literal, but not a variable. let me explain. I have a Company table which represents all companies that can sign in to my app. I have a Customer table which represents Customers for that Company.

customer.company is customer names names for that company.

the customer table is a child of the company table, linked by the company field

I am trying to retrieve all customers for a specific company who also have a record in my master Company table.

this query works, except of course rather than 'ABC Company' I need to make it a variable

SELECT comp.company FROM Customer c ,Company comp where comp.company = c.customer and c.company = 'ABC Company' group by comp.company order by c.customer

so this throws this "object is not an instance of declaring class" error where :myco is a string, with a value of ABC Company

SELECT comp.company FROM Customer c ,Company comp where comp.company = c.customer and c.company = :myco group by comp.company order by c.customer

I've looked at MK's discussion on this thread and tried and tried, but can't figure out how to address this properly. I freely admit I'm not really understanding hql

Anyone game for this one?

mkantor's picture

Look at your services tab on

Look at your services tab on the far left; look at the table definition in question where it lists all fields and relationships. Odds are you do not see the integer field there, only the relationship. This is how hibernate works; it removes your integer field (which means you can not query on it) and replaces it with the relationship object (which can be queried using something like employee.id = 5 instead of employeeId = 5).

This is very painful for those of us coming from an SQL background instead of a hibernate background, but once you get used to it, there are nice advantages to it as well.

Michael Kantor
SMTS; WaveMaker/SpringSource/VMware

Same issue here

I am experiencing the same problem. I can perform the query below when I hardcode aceCriteria, but once I try parameterizing it, I get the message "Run query error: object is not an instance of declaring class".

SELECT copt.id ,copt.description, copt.active, copt.aceCriteria FROM AceCriteriaOption copt WHERE copt.active=1 and copt.aceCriteria=:criteria

aceCriteria is a foreign key to an integer in another table. I am using bind type Integer for the parameter. I noticed I can select the related table as the bind type, but I'm not sure if that is correct (or what I would put for the test value)....

EDIT: By the way, I'm using 6.4.5GA, and the database backend is Microsoft SQL Server 2008.

Foreign key relationship

If anyone else runs into this, I figured out how to get it to work for me. It was indeed the foreign key relationship. Even though in my example copt.aceCriteria is an integer, it seems that I need to use the related table as the type. The Test Value is no longer just an integer, it's a JSON formatted object, with the key value. E.g., {"id":1}

Has anyone seen documentation confirming the above?

rocking's picture

i recall seeing something

i recall seeing something like that..but long ago. I cannot give you a straight answer just tips:

what happens when try with the whole path instead of sas.mobi4dServices (replacing sas with the whole string i mean)

is mob4dServices an integer?

JLuis
-
www.Preza.org/SPACEDWorks
Acoustic Guitar
Atmospheric Rock

Object not an instance of declaring class

Yes mobi4dServices is an integer. The issue is I get the error when I use paramters instead of static values. For example, sas.mobi4dServices=1 works. But when I change it to sas.mobi4dServices=:idNo and assign the parameter idNo with the value 1, I get the error.