I found resolution, sorry for all my typos too :) For someone else with the same issue, in the data-management.xml: <create-item> <sql>INSERT INTO tracking(visits, description, created) VALUES (#visits#, #description#, #created#)</sql> <id-query>SELECT LAST_INSERT_ID()</id-query> <!-- MySQL syntax to retrieve value of autoincremented column --> </create-item>
The <id-query>SELECT LAST_INSERT_ID()</id-query> solved issue. Cheers Wayne --- In flexcoders@yahoogroups.com, "wayne_badu_johnson" <wayne.a.john...@...> wrote: > > Hi all > > I am having some issues with createItem, oddly enough when I attempt to > create a second item, the first createItem works fine and pushes data. I have > seen a couple posts around this but no resolution. > > Flex 3 > Using lcds 2.6.1 > > The FaultResult: > Local.Call.Failed > faultString = "Item with id 'tracking.hibernate#:#0' already exists. Error > on destination 'tracking.hibernate'" > > I would assume that I would have to hadnle any id as the first record is > written correctly and auto-increment setup in table is all functioning as > expected. It looks like some reference is being tripped up when the second > attempt to create a new record is call. I have tried releasing/refreshing > fill etc but no go. > > > Any thoughts would be appreciated. > Cheers > Wayne > > > > > > Some snippets that I hope make sense: > > <!-- Tracking.as --> > package { > > [Managed] > [RemoteClass] > public class Tracking { > public function Tracking() {} > public var trackid:int; > public var description:String=""; > public var visits:String=""; > public var created:Date; > > } > } > > > <!-- MXML/AS --> > /** Call to create item */ > tracking = new Tracking(); > tracking.description = StringUtil.trim(descriptionInput.text); > tracking.visits = StringUtil.trim(visitsInput.text); > tracking.created = new Date(); > > var ir:ItemReference = hibernateUsers.createItem(tracking); > var token:AsyncToken = hibernateUsers.commit(); > > > > > <-- data-management.xml destination config --> > <destination id="tracking.hibernate"> > <properties> > <use-transactions>true</use-transactions> > <source>flex.data.assemblers.SQLAssembler</source> > <scope>application</scope> > <metadata> > <identity property="trackid"/> > </metadata> > <network> > <session-timeout>20</session-timeout> > <paging enabled="false" pageSize="20"/> > <throttle-inbound policy="IGNORE" max-frequency="50"/> > <throttle-outbound policy="IGNORE" max-frequency="500"/> > </network> > <server> > <database> > > <driver-class>com.mysql.jdbc.Driver</driver-class> > <url>jdbc:mysql://localhost:3306/xxxxxxdb</url> > <username>xxxx</username> > <password>xxxx</password> > <login-timeout>30</login-timeout> > </database> > <fill> > <name>all</name> > <sql>SELECT * FROM tracking</sql> > </fill> > <get-item> > <sql>SELECT * FROM tracking WHERE trackid = > #trackid#</sql> > </get-item> > <create-item> > <sql>INSERT INTO tracking > (visits, description, > created) > VALUES (#visits#, > #description#, #created#)</sql> > </create-item> > <update-item> > <sql>UPDATE tracking SET visits=#visits#, > description=#description#, created=#created# > WHERE > trackid=#_PREV.trackid#</sql> > </update-item> > <delete-item> > <sql>DELETE FROM tracking WHERE > trackid=#trackid#</sql> > </delete-item> > <count> > <name>all</name> > <sql>SELECT count(*) FROM tracking</sql> > </count> > <count> > <name>exists</name> > <sql>SELECT count(*) FROM tracking WHERE > description = #description#</sql> > </count> > </server> > </properties> > </destination> >