1 package mircoders.storage;
8 import freemarker.template.*;
15 * <b>Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle
20 public class DatabaseMedia extends Database implements StorageObject{
22 private static DatabaseMedia instance;
23 private static EntityRelation relationMediaType;
25 // the following *has* to be sychronized cause this static method
26 // could get preemted and we could end up with 2 instances of DatabaseFoo..
27 // see the "Singletons with needles and thread" article at JavaWorld -mh
28 public synchronized static DatabaseMedia getInstance()
29 throws StorageObjectException {
30 if (instance == null) {
31 instance = new DatabaseMedia();
32 instance.myselfDatabase = instance;
37 private DatabaseMedia() throws StorageObjectException
40 //this.cache = new DatabaseCache(100);
41 this.hasTimestamp = false;
42 this.theTable="media";
43 relationMediaType = new EntityRelation("to_media_type", "id",
44 DatabaseMediaType.getInstance(), EntityRelation.TO_ONE);
46 this.theEntityClass = Class.forName("mircoders.entity.EntityMedia");
49 throw new StorageObjectException(e.toString());
57 * returns the comments that belong to the article (via entityrelation)
58 * where db-flag is_published is true
60 public Entity getMediaType(Entity ent) throws StorageObjectException {
63 type = relationMediaType.getOne(ent);
65 catch (StorageObjectException e) {
66 theLog.printError("DatabaseMedia :: failed to get media_type");
67 throw new StorageObjectException("DatabaseMedia :"+e.toString());