private static DatabaseContentToTopics instance;
- public static DatabaseContentToTopics getInstance()
+ // the following *has* to be sychronized cause this static method
+ // could get preemted and we could end up with 2 instances of DatabaseFoo.
+ // see the "Singletons with needles and thread" article at JavaWorld -mh
+ public synchronized static DatabaseContentToTopics getInstance()
throws StorageObjectException {
if (instance == null) {
instance = new DatabaseContentToTopics();
super();
this.hasTimestamp = false;
this.theTable="content_x_topic";
+ try { this.theEntityClass = Class.forName("mir.entity.GenericEntity"); }
+ catch (Exception e) { throw new StorageObjectException(e.toString()); }
+
}
/**
}
return returnList;
}
-
+
/**
* Returns a ArrayList of Integer-Objects from a content-id.
* @returns ArrayList
Collection hasTopics = getTopicsOfContent(contentId);
Collection toSet = new ArrayList();
Collection toDelete = new ArrayList();
-
+
if(hasTopics!=null && hasTopics.size()>0){
//now we check if there are new topics and copy them to an array.
for(int i = 0; i< topicId.length;i++){
toSet.add(topicId[i]);
}
}
-
+
//first delete all row with content_id=contentId
String sql = "delete from "+ theTable +" where content_id=" + contentId
+ " and topic_id in (";