Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Object Relational Mapping and the fly likes How do  I avoid duplicate inserts in YoutubeFeed table? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "How do  I avoid duplicate inserts in YoutubeFeed table?" Watch "How do  I avoid duplicate inserts in YoutubeFeed table?" New topic
Author

How do I avoid duplicate inserts in YoutubeFeed table?

rsheyeah hussain
Greenhorn

Joined: Jan 10, 2010
Posts: 11
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:



[Thumbnail for testprblm copy.jpg]

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I avoid duplicate inserts in YoutubeFeed table?
 
Similar Threads
Hibernate - Creating .hbm file for link table
elt column hibernate
Hibernate Composite keymapping
autogenerating db-schema cascade=CascadeType.REMOVE but no ON DELETE CASCADE
NonUniqueObjectException