All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.spun.util.database.DatabaseLoadingTracker Maven / Gradle / Ivy

There is a newer version: 24.9.0
Show newest version
package com.spun.util.database;

import java.util.HashMap;

public class DatabaseLoadingTracker
{
  private HashMap loaded = null;
  public DatabaseLoadingTracker()
  {
    loaded = new HashMap();
  }
  private String getHashKey(DatabaseObject object)
  {
    return object.getClass().getName() + object.getPkey();
  }
  /**
    * loads the chache from the database
    **/
  public DatabaseObject load(DatabaseObject newObject)
  {
    if (newObject == null)
    { return null; }
    String hashKey = getHashKey(newObject);
    DatabaseObject oldObject = (DatabaseObject) loaded.get(hashKey);
    if (oldObject == null)
    {
      oldObject = newObject;
      loaded.put(hashKey, newObject);
    }
    else
    {
      //My_System.event("found duplicate of " + hashKey);
    }
    return oldObject;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy