Consider the following @Entity with an @Embeddable mapping:
@Entity
public class MyEntity {
@Embedded
private MyEmbeddable myEmbeddable;
}
@Embeddable
public class MyEmbeddable implements Serializable {
private String myField;
@PostLoad
public void onPostLoad() { }
}
For the above mapping the @PostLoad method in MyEmbeddable is invoked when an instance of MyEntity is loaded. However, when MyEmbeddable is used in an @ElementCollection, @PostLoad is not invoked for the collection elements upon initialization of the collection.
@Entity
public class MyEntity {
@ElementCollection
@CollectionTable(name = "my_embeddable_collection")
private Set<MyEmbeddable> myEmbeddableCollection;
}
@Embeddable
public class MyEmbeddable implements Serializable {
private String myField;
@PostLoad
public void onPostLoad() { }
}
|