package mircoders.storage;
-import java.sql.Connection;
-import java.sql.Statement;
-
import mir.log.LoggerWrapper;
import mir.storage.Database;
-import mir.storage.StorageObjectFailure;
+import mir.storage.DatabaseFailure;
-/**
- * <b>this class implements the access to the content-table</b>
- *
- *
- */
+import java.sql.Connection;
+import java.sql.Statement;
public class DatabaseContent extends Database {
private static DatabaseContent instance;
- // Contructors / Singleton
-
- // 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 DatabaseContent getInstance() {
if (instance == null ) {
return instance;
}
- private DatabaseContent() throws StorageObjectFailure {
+ private DatabaseContent() throws DatabaseFailure {
super();
mainTable="content";
- primaryKeySequence="media_id_seq";
logger = new LoggerWrapper("Database.Content");
entityClass = mircoders.entity.EntityContent.class;
* sets the database flag is_produced to unproduced
*/
- public void setUnproduced(String where) throws StorageObjectFailure
+ public void setUnproduced(String where) throws DatabaseFailure
{
Connection con=null;Statement stmt=null;
String sql = "update content set is_produced='0' where " + where;
finally { freeConnection(con,stmt);}
}
- /**
- *
- * @param id
- * @return
- * @throws StorageObjectFailure
- */
-
- public boolean delete(String id) throws StorageObjectFailure
- {
+ public boolean delete(String id) throws DatabaseFailure {
DatabaseComment.getInstance().deleteByContentId(id);
DatabaseContentToTopics.getInstance().deleteByContentId(id);
DatabaseContentToMedia.getInstance().deleteByContentId(id);
return super.delete(id);
}
+ protected String getPrimaryKeySequence() {
+ return "media_id_seq";
+ }
}