• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do I avoid duplicate inserts in YoutubeFeed table?

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am searching n fetching records from the youtubeapi and populating it in the youtubefeed table. I have a "searchkeywords" table and a" youtubefeed" result table.
In all of the three tables, ID is the primary key, and in youtubefeed table, youtubeid is the unique key.

Many 2 Many relationship
1 keyword can have many results.
1 result can be associated with many keywords
KeywordSearchResult is the link table

When I run a search against the Youtube API,


For the keyword in searchKeywords table
1. kitchen appliances,
I get the result with the following youtubefeedID
1. LMTRE
2. MNTER
3. NOPOK

For the keyword in searchKeywords table
2. kitchen crockery,
I get the reseult with the following youtubefeedID
4. LMTRE
5. MNTER
6. NOPOK
How do I avoid duplicate inserts in YoutubeFeed table?
YoutubefeedID is set to be unique.

Question:
Even if I use saveorUpdate() , insert statements get generated even if the reocord already exists.
Do I check in keywordSearchResult table if the particular keyword and youtubefeedID result already exists and then write the insert logic ???

Searchkeywords.hbm.xml






Youtubefeed.hbm.xml


Question:
Even if I use saveorUpdate() , insert statements get generated even if the reocord already exists.
Do I check in keywordSearchResult table if the particular keyword and youtubefeedID result already exists and then write the insert logic ???
SQL:

testprblm-copy.jpg
[Thumbnail for testprblm-copy.jpg]
 
I didn't do it. You can't prove it. Nobody saw me. The sheep are lying! This tiny ad is my witness!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic