I'm guessing this is because you are assuming the category (or dyp or whatever) already exists in the database (your doing a get) but I think you've got a bug here... is* i *really the value you want to retrieve "dyp" with? or should it be item?
for(i=1;i lte listLen(arguments.data.categories);i=i+1) { item=ListGetAt(arguments.data.categories,i); cat = variables.transferObj.get(*"**dyp", i)*; v.addCategories(cat); } What will happen here is that if there is no dyp for one of the values of i (not item, i) you will get a new unpersisted dyp object. And then when you try to save the video it won't be able to because that dyp hasn't been saved. On Tue, Jan 27, 2009 at 6:55 AM, systemseven <systemsevendesi...@gmail.com>wrote: > > Mark, > > Makes sense, but I'm not sure how to tell transfer what it needs to > know. Here is the full code from my save function. Maybe that will > help you point me in the right direction. > > > if(len(trim(arguments.data.id))) > { > v = > variables.transferObj.get('video',arguments.data.id); > v.setModifiedDate(now()); > } > else > { > v = > variables.transferObj.new('video'); > v.setCreatedDate(now()); > uuid = CreateUUID(); > } > > if(len(trim(uuid))) > { > v.setId(uuid); > } > > v.setTitle(arguments.data.title); > v.setSummary(arguments.data.summary); > v.setFullStory(arguments.data.fullStory); > v.setVideoFile(arguments.data.videoFile); > v.setInPodcast(arguments.data.inPodcast); > v.setInRSS(arguments.data.inRSS); > v.setOnHomepage(arguments.data.onHomepage); > > v.setSendToTwitter(arguments.data.sendToTwitter); > > v.setPostingDate(postingDate); > > if(arguments.data.onHomepage) > { > v.setHomeDate(homeDate); > } > > if(arguments.data.sendToTwitter){ > v.setTwitterDate(twitterDate); > } > > if(len(trim(arguments.data.thumbnail))){ > > v.setThumbnailFile(arguments.data.thumbnail); > } > > if(len(trim(arguments.data.preview))){ > > v.setPreviewFile(arguments.data.preview); > } > > if(arguments.data.inPodcast){ > > v.setPodcastFile(arguments.data.podcastFile); > } > > //assign the categories, first clear them > v.clearCategories(); > > for(i=1;i lte > listLen(arguments.data.categories);i=i+1) > { > > item=ListGetAt(arguments.data.categories,i); > cat = > variables.transferObj.get("dyp", i); > v.addCategories(cat); > } > //clear tag association, add new tags, > assign tags to this item > v.clearTags(); > > for(i=1; i lte ListLen(arguments.data.tags); > i=i+1){ > item = > ListGetAt(arguments.data.tags,i); > //create the tag transfer object > t = > variables.transferObj.new('tag'); > t.setId(CreateUUID()); > t.setTagText(item); > //save it > variables.transferObj.save(t); > //associate it with this video > v.addTags(t); > } > > variables.transferObj.save(v); > > On Jan 27, 7:46 am, Mark Mandel <mark.man...@gmail.com> wrote: > > You are trying to save a video, which has a 'dyp' that has not been > > persisted in the database. > > > > This means Transfer doesn't know what PK value to use for the object. > > > > Mark > > > > On Tue, Jan 27, 2009 at 11:40 PM, systemseven > > > > > > > > <systemsevendesi...@gmail.com> wrote: > > > > > In TransferObject 'video' manytomany 'dyp' has not been persisted in > > > the database. > > > > > I have a video table that is joined to both a category table and a tag > > > table > > > > > In my transfer.xml category and tag are both manytomany relationships > > > with the video object > > > > > When saving the object, the tags get saved but the categories do not > > > get added to the join table, it throws an error: > > > In TransferObject 'video' manytomany 'dyp' has not been persisted in > > > the database. > > > > > Is this a common problem? Am I just overlooking something obvious? > > > > > ====TRANSFER.XML=== > > > <transfer> > > > <objectDefinitions> > > > <object name="video" table="videoManager"> > > > <id name="id" type="string" /> > > > <property name="title" type="string" /> > > > <property name="summary" type="string" /> > > > <property name="fullstory" type="string" /> > > > <property name="videoFile" type="string" /> > > > <property name="thumbnailFile" type="string" > nullable="true"/> > > > <property name="previewFile" type="string" > nullable="true"/> > > > <property name="podcastFile" type="string" > nullable="true"/> > > > <property name="inPodcast" type="numeric" /> > > > <property name="inRSS" type="numeric" /> > > > <property name="onHomepage" type="numeric" /> > > > <property name="sendToTwitter" type="numeric" /> > > > <property name="postingDate" type="date" /> > > > <property name="twitterDate" type="date" > nullable="true"/> > > > <property name="homeDate" type="date" > nullable="true"/> > > > <property name="createdDate" type="date" /> > > > <property name="modifiedDate" type="date" /> > > > > > <manytomany name="categories" > table="vm_categories"> > > > <link to="video" column="videoId"/> > > > <link to="dyp" column="dypId"/> > > > <collection type="array"> > > > <order property="title" > order="asc"/> > > > </collection> > > > </manytomany> > > > > > <manytomany name="tags" table="vm_tags"> > > > <link to="video" column="videoId"/> > > > <link to="tag" column="tagId"/> > > > <collection type="array"> > > > <order property="tagText" > order="asc"/> > > > </collection> > > > </manytomany> > > > > > </object> > > > > > <object name="dyp" table="dyp_categories"> > > > <id name="id" type="string" /> > > > <property name="title" type="string" /> > > > </object> > > > > > <object name="tag" table="tags"> > > > <id name="id" type="string" /> > > > <property name="tagText" type="string" /> > > > </object> > > > > > </objectDefinitions> > > > </transfer> > > > =========== > > > > > =====SAVE FUNCTION===== > > > v.clearCategories(); > > > > > for(i=1;i lte > listLen(arguments.data.categories);i=i+1) > > > { > > > > item=ListGetAt(arguments.data.categories,i); > > > cat = > variables.transferObj.get("dyp", i); > > > v.addCategories(cat); > > > } > > > > > ======================== > > > > -- > > E: mark.man...@gmail.com > > W:www.compoundtheory.com > > > --~--~---------~--~----~------------~-------~--~----~ Before posting questions to the group please read: http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer You received this message because you are subscribed to the Google Groups "transfer-dev" group. To post to this group, send email to transfer-dev@googlegroups.com To unsubscribe from this group, send email to transfer-dev-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/transfer-dev?hl=en -~----------~----~----~----~------~----~------~--~---