All pastes #272063 Raw Edit

Untitled

public text v1 · immutable
·published 2006-12-08 18:17 UTC
rendered paste body

package bugs.toplink.serializable;

import java.io.Serializable;
import java.util.HashMap;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.PostUpdate;
import javax.persistence.Transient;

@Entity
public class Employee {

  @Id
  @GeneratedValue
  private Long id;
  
  @Basic(fetch = FetchType.LAZY)
  private String fDescription;
  
  private HashMap<String, Serializable> properties = new HashMap<String, Serializable>();

  @Transient
  private static Runnable updateListener;

  public Employee() {
    fDescription = "Hello World";
  }

  public Long getId() {
    return id;
  }

  public void putProperty(String key, Serializable s) {
    properties.put(key, s);
  }

  public Serializable getProperty(String key) {
    return properties.get(key);
  }

  public static void setListener(Runnable listener) {
    updateListener = listener;
  }

  @PostUpdate
  public void postUpdate() {
    if (updateListener != null) {
      updateListener.run();
    }
  }
  
  public String getDescription() {
    return fDescription;
  }

  public HashMap<String, Serializable> getProperties() {
    return properties;
  }
}