• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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]
 
Check your pockets for water buffalo. You might need to use this tiny ad until locate a water buffalo:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic