Copy link to clipboard
Copied
Hi, there!
Sr for that question, because it should be pretty easy to answer, but i'm totally new to coldfusion
and googled for about an hour now. I have a orm DTO.cfc:
<cfcomponent entityname="testDTO" persistent="true" table="test" schema="informix" output="false">
<!---- properties ---->
</cfcomponent>
and have a service Methode in test.cfc
<!---- Add test---->
<cffunction name="createTest" returntype="testDTO" access="remote">
<cfargument name="item" type="testDTO" required="true" />
<!---- Auto-generated method
Insert a new record in test---->
<cfset entitysave(item) />
<!---- return created item ---->
<cfreturn item/>
</cffunction>
i try to call via the the <cfInvoke>-Tag
<cfset lieferant = entityNew('test')>
<cfinvoke
component="#request.componentbase#.test"
method="createTest"
item="#test#"
returnvariable="test">
but the error
'The ITEM argument passed to the createLieferant function is not of type testDTO.'
appears on function call. I just can't find a way to tell cf that lieferant is of type testDTO.
When i type the methodes parameter to struct the methode call works well.
Thanks for your help in advance!
Florian
Copy link to clipboard
Copied
Hi NewFlo,
Though i have not worked with ORM, but it seems error is not related to ORM. It is simply type mismatch.
The value you are passing to the function "createTest" is not a object of "testDTO".
I think the problem is your calling, you are providing wrong value for "item" which should be object of "testDTO".
Thanks
Saurav
Copy link to clipboard
Copied
Thx for your reply.
But you got me wrong on the problem i have.
I understand what the error wants to tell me, but i don't
know why the error happens.
I create a variable using the entity Method, passing the class name testDTO
<cfset test = entitynew("testDTO")>
In my opinion the should result in the variable set to type testDTO.
Wenn i dump the variable it also shows this class name as header of the structure.
But when i try to pass the var to the methode the error appears.
I also tried the createObject-Methode resulting in the same error.
all the best,
florian
Copy link to clipboard
Copied
I'm assuming your extract there isn't quite right:
<cfset lieferant = entityNew('test')>
<cfinvoke
component="#request.componentbase#.test"
method="createTest"
item="#test#"
returnvariable="test">
You're doing item="#test#", surely this should be item="#lieferant#"?
In which case, you've done <cfset lieferant = entityNew('test')>, which is of type "test", not "testDTO"?
If you're still having trouble, remove the item="" attribute from CFINVOKE and use CFINVOKEARGUMENTs instead.
Copy link to clipboard
Copied
@Owain
You are right, sorry for that i was in a hurry and made a mistake changing my var names for the example.
I will give the CFINVOKEARGUMENTs a try as soon as i find time to play around with the orm feature
again. Thx for your reply!
Copy link to clipboard
Copied
From the example you've given, the type is DTO(name of CFC), not testDTO.