0

I am trying to find out why my @PostLoad annotated method never gets invoked after loading the object from the database:

@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "key.job", targetEntity = ScheduledJobParam.class, orphanRemoval = true)
@XmlTransient
private Set<ScheduledJobParam> paramSet;

@Transient
private Map<String, ScheduledJobParam> params;

@PostLoad
public void indexParameters() {

    this.params = new HashMap<>();

    for(ScheduledJobParam param : this.paramSet) {

        String paramName = param.getKey().getName();
        this.params.put(paramName, param);
    }
}

The reason I need it is because children rows are loaded in a Set but I would like to put them in a Map for easy retrieval by key:

public String getParameterValue(String _paramName) {
    String result = null;
    ScheduledJobParam param = this.params.get(_paramName);

    if(param != null) {
        result = param.getValue();
    }

    return result;
}

My JPA provider is Hibernate.

amphibient
  • 29,770
  • 54
  • 146
  • 240

0 Answers0