Title: Message

Hi,

I'm just getting started with Reactor (and Model Glue) and have encountered the following problem. This may have been asked before and resolved. If so, I apologise, but have been unable to find an answer anywhere else. (http://www.mail-archive.com/[email protected]/msg01718.html was about as close as I could get)...

I am trying to update a record as per the documentation. Code as follows:

 

<cfset Reactor = CreateObject('component','reactor.reactorFactory').init(expandPath('reactor.xml'))>

<cfset productRecord = reactor.createRecord(a_products').load(ProductCode="DA000013")>

<cfset productRecord.setTitle1("Testing")>

<cfset productRecord.save()>

 

However, this causes the following error:

------------------------------------------

Error Executing Database Query.

[Macromedia][SQLServer JDBC Driver][SQLServer]Violation of PRIMARY KEY constraint 'PK_a_Products'. Cannot insert duplicate key in object 'dbo.a_products'.

The error occurred in D:\CFusionMX7\reactor\project\ReactorTest\Dao\a_productsDao.cfc: line 1651 Called from D:\CFusionMX7\reactor\project\ReactorTest\Dao\a_productsDao.cfc: line 15 Called from D:\CFusionMX7\reactor\base\abstractRecord.cfc: line 112 Called from D:\CFusionMX7\reactor\base\abstractRecord.cfc: line 103 Called from D:\CFusionMX7\reactor\base\abstractRecord.cfc: line 93 Called from D:\CFusionMX7\wwwroot\ReactorTest\index.cfm: line 11 Called from D:\CFusionMX7\reactor\project\ReactorTest\Dao\a_productsDao.cfc: line 1651 Called from D:\CFusionMX7\reactor\project\ReactorTest\Dao\a_productsDao.cfc: line 15 Called from D:\CFusionMX7\reactor\base\abstractRecord.cfc: line 112 Called from D:\CFusionMX7\reactor\base\abstractRecord.cfc: line 103 Called from D:\CFusionMX7\reactor\base\abstractRecord.cfc: line 93 Called from D:\CFusionMX7\wwwroot\ReactorTest\index.cfm: line 11

1649 : <cfif Convention.supportsMultiStatementQueries() AND Convention.supportsIdentity() >

1650 : #Convention.lastInsertedIdSyntax(getObjectMetadata())#

1651 : </cfif>

1652 : </cfquery>

1653 :

-------------------------------------------

I looked in the a_productsDao.cfc and there is the following piece of code that decides if it is to be an update() or a create():

<cfif IsNumeric(arguments.to.ProductCode) AND Val(arguments.to.ProductCode)>

<cfset update(arguments.to) />

<cfelse>

<cfset create(arguments.to) />

</cfif>

The error occurred on the line <cfset create(arguments.to) />. Maybe it has something to do with a non-incremental primary key..? Anyway, this should not be creating a new record but should be updating an existing one.

I tried the same code (but a different database) in MySQL 5 and it worked without any problem.

I tried similar code but on an MS SQL database but this time with a numeric incremental primary key. The following error was thrown:

Oops!

Message Ambiguous Record

Detail Your request matched more than one record.

Extended Info

Tag Context D:\CFusionMX7\reactor\project\ICGFeeds\Dao\Email_TemplateDao.cfc (141) D:\CFusionMX7\reactor\base\abstractRecord.cfc (64) D:\CFusionMX7\wwwroot\ICGFeeds\controller\contEmails.cfc (538) D:\CFusionMX7\wwwroot\ModelGlue\unity\listener\Listener.cfc (26) D:\CFusionMX7\wwwroot\ModelGlue\unity\eventrequest\MessageBroadcaster.cfc (32) D:\CFusionMX7\wwwroot\ModelGlue\unity\framework\ModelGlue.cfc (332) D:\CFusionMX7\wwwroot\ModelGlue\unity\framework\ModelGlue.cfc (290) D:\CFusionMX7\wwwroot\ModelGlue\unity\framework\ModelGlue.cfc (263) D:\CFusionMX7\wwwroot\ModelGlue\unity\ModelGlue.cfm (58) D:\CFusionMX7\wwwroot\ModelGlue\ModelGlue.cfm (1) D:\CFusionMX7\wwwroot\ICGFeeds\index.cfm (27)

It seems that there is a bug somewhere in the MS SQL code.

I am running revision 330 from the subversion repository.

Any help would be appreciated.

Tom

 
 

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[email protected]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Reply via email to