Google Groups Home
Help | Sign in
Primary Keys that aren't incremental
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Stephen Moretti  
View profile
 More options May 9, 12:45 pm
From: "Stephen Moretti" <stephen.more...@gmail.com>
Date: Fri, 9 May 2008 17:45:24 +0100
Local: Fri, May 9 2008 12:45 pm
Subject: Primary Keys that aren't incremental

I suspect I'm being really dim (as usual)

I have a primary key which is a supplied value from a data import -
basically a clients internal stock id for a "product".

How do I persuade Transfer to let me set my own key?

I've tried :
<id name="ID" column="StockID" type="numeric"  />
and
<id name="ID" column="StockID" type="numeric" generate="true" />

The first throws a  SQL error because the insert is not including the ID in
the INSERT statement, as the database requires a value and there is no
default set for it.
The second inserts an incremental ID that Transfer is kindly generating and
not inserting the ID that I set using objProduct.setID(blah)

I'm using Winders, CF8, MySQL 5.x and the latest Transfer from SVN.
I did try reading the docs and searching, but don't seem to be able to hit
on what I'm after.  The stupid thing is I'm sure I've done this before, but
can't find it, nor can I remember what I did!

Thanks for the help

Regards

Stephen


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Casey Corcoran  
View profile
 More options May 9, 12:49 pm
From: Casey Corcoran <casey.corco...@gmail.com>
Date: Fri, 09 May 2008 12:49:45 -0400
Local: Fri, May 9 2008 12:49 pm
Subject: Re: [transfer-dev] Primary Keys that aren't incremental

      This is from the docs, sounds like what you're looking for...

      http://docs.transfer-orm.com/wiki/Primary_Key_Management.cfm

      Manual

Lastly, this can all be manually overwritten simply by setting the
primary key value via the set() method prior to the TransferObject being
created in the database, e.g.

||

user = getTransfer().new("User");
user.setUserID(1);
getTransfer().save(user);

This will attempt to insert the User record into the database with a ID
of '1'.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stephen Moretti  
View profile
 More options May 10, 3:24 pm
From: "Stephen Moretti" <stephen.more...@gmail.com>
Date: Sat, 10 May 2008 20:24:37 +0100
Local: Sat, May 10 2008 3:24 pm
Subject: Re: [transfer-dev] Re: Primary Keys that aren't incremental

2008/5/9 Casey Corcoran <casey.corco...@gmail.com>:

Yeah - thanks Casey.  This is why I'm confused and thinking I'm being dim...
I've read this already.

In both of the examples I give I am doing a setID() and, as I said, in the
first example the ID column is not in the query and in the second Transfer
is ignoring the setID() and generating an incrementing ID for me. :/

I'll have a bit more of a dig on monday...  I'll see if the ID is actually
being set in the object, despite the line of code being right there, before
I do the save and if it is I'll dig deeper into Transfer to see what why it
might be being skipped over.

Regards

Stephen


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google