Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#34 Hibernate Creates Duplicate Entries

open
nobody
None
5
2006-01-03
2006-01-03
Josh K
No

Here is a method which I created:

public FeedIF getFeed(URL url){
FeedIF feed = null;
try{
if(this.hasFeed(url)){
feed = manager.getFeed(url.toString());
}else{
manager.getChannelBuilder().beginTransaction();
feed = manager.addFeed(url.toString());
manager.getChannelBuilder().endTransaction();
}
}catch(Exception e){
e.printStackTrace(System.out);
}
return feed;
}

I've initialized my manager with a Hibernate
ChannelBuilder, and configured my database. When I
initially start up my test case and call this method
with a URL, it works as expected, and creates rows in
channels and items. I can use this URL as much as I
like and I only get one channel row for that URL.

When I stop my JVM and restart it, I get a new row in
the database for the same URL. It appears that the
code is not checking properly for feeds in the
database, and only checks the feed cache.

There is a topic on this issue in the open discussions
section of sourceforge which may help fix the problem.

Discussion