public interface MediaEntity extends MetadataObject
Specifies a media class with metadata that can be persisted using the Java Persistence API. All media entities must provide a Java long persistent identifier and an index that is used to order values if the entity is persisted as part of a strong reference vector.
The implementing class or one of its superclasses must provide fields "persistentID"
and "persistentIndex" so that the JPA implementation can create and manipulate
objects as appropriate. Here is an example of the required code:
private Long persistentID = null;
private int persistentIndex = 0;
public Long getPersistentID() {
return persistentID;
}
public void setPersistentIndex(
int index) {
this.persistentIndex = index;
}
Once these fields are provided and the methods are implemented, entities can be managed
by an appropriately configured entity manager. The configuration is generated by the
JPAGenerator.generateORM(java.util.Collection, String) method.
| Modifier and Type | Method and Description |
|---|---|
MediaEntity |
clone()
Create a cloned copy of this media entity.
|
Long |
getPersistentID()
Returns the persistent identifier for this media entity.
|
void |
setPersistentIndex(int index)
If the media entity is an element of a strong reference vector, set the index of
that element in the vector just before the value is persisted.
|
Long getPersistentID()
Returns the persistent identifier for this media entity. This will be automatically generated by the persistence provider when the object is persisted for the first time. Before this, the identifier will be null.
void setPersistentIndex(int index)
If the media entity is an element of a strong reference vector, set the index of that element in the vector just before the value is persisted. When the value is retrieved, the index will be used to restore the item to the correct position in its list. This is required to overcome a shortcoming of the Java Persistence API when persisting ordered collections.
index - Index of the entity within the list that contains it.MediaEntity clone()
Create a cloned copy of this media entity. This is required for all targets of a strong reference to ensure that the target of a reference is owned by its source object.
(c)2007-2016 Richard Cartwright, all rights reserved. Licensed under Apache 2 license and subject to the AMWA IPR policy.