Package org.ofbiz.core.entity
Class GenericValue
java.lang.Object
java.util.Observable
org.ofbiz.core.entity.GenericEntity
org.ofbiz.core.entity.GenericValue
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<GenericEntity>,Map<String,Object>
Generic Entity Value Object - Handles persisntence for any defined entity.
Created Wed Aug 08 2001
- Version:
- 1.0
- Author:
- David E. Jones, Eric Pabst
- See Also:
-
Nested Class Summary
-
Field Summary
FieldsModifier and TypeFieldDescriptionThis Map will contain the original field values from the database iff this GenericValue came from the database.HashMap to cache various related entity collectionsHashMap to cache various related cardinality on entity collectionsFields inherited from class org.ofbiz.core.entity.GenericEntity
delegatorName, entityName, fields, internalDelegator, modelEntity, modified -
Constructor Summary
ConstructorsConstructorDescriptionGenericValue(GenericDelegator internalDelegator, ModelEntity modelEntity) Creates new GenericValueGenericValue(GenericDelegator internalDelegator, ModelEntity modelEntity, Map<String, ?> fields) Creates new GenericValue from existing MapGenericValue(GenericPK primaryKey) Creates new GenericValue from existing GenericValueGenericValue(GenericValue value) Creates new GenericValue from existing GenericValueGenericValue(ModelEntity modelEntity) Deprecated.GenericValue(ModelEntity modelEntity, Map<String, ?> fields) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionclone()Clones this GenericValue, this is a shallow clone & uses the default shallow HashMap clonevoidThis should only be called by the Entity Engine once a GenericValue has been read from the database so that we have a copy of the original field values from the Db.create()getOriginalDbValue(String name) getRelated(String relationName) Get the named Related Entity for the GenericValue from the persistent storeGet the named Related Entity for the GenericValue from the persistent storegetRelatedByAnd(String relationName, Map<String, ?> fields) Get the named Related Entity for the GenericValue from the persistent store and filter itgetRelatedByAndCache(String relationName, Map<String, ?> fields) Get the named Related Entity for the GenericValue from the persistent store and filter it, looking first in the global generic cache (for the moment this isn't true, is same as EmbeddedCache variant)getRelatedByAndEmbeddedCache(String relationName, Map<String, ?> fields) Get the named Related Entity for the GenericValue from the persistent store and filter it, looking first in a cache associated with this entity which is destroyed with this ValueObject when no longer used.getRelatedCache(String relationName) Get the named Related Entity for the GenericValue from the persistent store, looking first in the global generic cache (for the moment this isn't true, is same as EmbeddedCache variant)Get the named Related Entity for the GenericValue from the persistent store, looking first in the global generic cache (for the moment this isn't true, is same as EmbeddedCache variant)getRelatedDummyPK(String relationName) Get a dummy primary key for the named Related Entity for the GenericValuegetRelatedDummyPK(String relationName, Map<String, ?> byAndFields) Get a dummy primary key for the named Related Entity for the GenericValuegetRelatedEmbeddedCache(String relationName) Get the named Related Entity for the GenericValue from the persistent store, looking first in a cache associated with this entity which is destroyed with this ValueObject when no longer used.Get the named Related Entity for the GenericValue from the persistent store, looking first in a cache associated with this entity which is destroyed with this ValueObject when no longer used.getRelatedMulti(String relationNameOne, String relationNameTwo) Get the named Related Entity for the GenericValue from the persistent store across another Relation.getRelatedMulti(String relationNameOne, String relationNameTwo, List<String> orderBy) Get the named Related Entity for the GenericValue from the persistent store across another Relation.getRelatedOne(String relationName) Get the named Related Entity for the GenericValue from the persistent storegetRelatedOneCache(String relationName) Get the named Related Entity for the GenericValue from the persistent store, looking first in the global generic cache (for the moment this isn't true, is same as EmbeddedCache variant)getRelatedOneEmbeddedCache(String relationName) Get the named Related Entity for the GenericValue from the persistent store, looking first in a cache associated with this entity which is destroyed with this ValueObject when no longer used.getRelatedOrderBy(String relationName, List<String> orderBy) Get the named Related Entity for the GenericValue from the persistent store and order itgetRelatedOrderByCache(String relationName, List<String> orderBy) Get the named Related Entity for the GenericValue from the persistent store and order it, looking first in the global generic cache (for the moment this isn't true, is same as EmbeddedCache variant)getRelatedOrderByEmbeddedCache(String relationName, List<String> orderBy) Get the named Related Entity for the GenericValue from the persistent store and order it, looking first in a cache associated with this entity which is destroyed with this ValueObject when no longer used.booleanvoidrefresh()voidremove()voidremoveRelated(String relationName) Remove the named Related Entity for the GenericValue from the persistent storevoidstore()Methods inherited from class org.ofbiz.core.entity.GenericEntity
addToXmlDocument, clear, compareTo, containsKey, containsPrimaryKey, containsValue, dangerousGetNoCheckButFast, dangerousSetNoCheckButFast, entrySet, equals, get, get, getAllFields, getAllKeys, getBoolean, getBytes, getDate, getDelegator, getDouble, getEntityName, getFields, getFloat, getInteger, getLong, getModelEntity, getPrimaryKey, getString, getTime, getTimestamp, hashCode, isEmpty, isModified, isPrimaryKey, keySet, lockEnabled, makeXmlDocument, makeXmlElement, makeXmlElement, matchesFields, put, putAll, remove, set, set, setBytes, setDelegator, setFields, setNonPKFields, setNonPKFields, setPKFields, setPKFields, setString, size, toString, values, writeXmlTextMethods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChangedMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
originalDbValues
This Map will contain the original field values from the database iff this GenericValue came from the database. If it was made manually it will no have this Map, ie it will be null to not take up memory.
-
Constructor Details
-
GenericValue
Creates new GenericValue- Since:
- 1.0.13
-
GenericValue
public GenericValue(GenericDelegator internalDelegator, ModelEntity modelEntity, Map<String, ?> fields) Creates new GenericValue from existing Map- Since:
- 1.0.13
-
GenericValue
Deprecated.Creates new GenericValue -
GenericValue
Deprecated.Creates new GenericValue from existing Map -
GenericValue
Creates new GenericValue from existing GenericValue -
GenericValue
Creates new GenericValue from existing GenericValue
-
-
Method Details
-
create
- Throws:
GenericEntityException
-
store
- Throws:
GenericEntityException
-
remove
- Throws:
GenericEntityException
-
refresh
- Throws:
GenericEntityException
-
originalDbValuesAvailable
public boolean originalDbValuesAvailable() -
getOriginalDbValue
-
copyOriginalDbValues
public void copyOriginalDbValues()This should only be called by the Entity Engine once a GenericValue has been read from the database so that we have a copy of the original field values from the Db. -
getRelated
Get the named Related Entity for the GenericValue from the persistent store- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition file- Returns:
- List of GenericValue instances as specified in the relation definition
- Throws:
GenericEntityException
-
getRelated
public List<GenericValue> getRelated(String relationName, Map<String, ?> byAndFields, List<String> orderBy) throws GenericEntityExceptionGet the named Related Entity for the GenericValue from the persistent store- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition filebyAndFields- the fields that must equal in order to keep; may be nullorderBy- The fields of the named entity to order the query by; may be null; optionally add a " ASC" for ascending or " DESC" for descending- Returns:
- List of GenericValue instances as specified in the relation definition
- Throws:
GenericEntityException
-
getRelatedCache
Get the named Related Entity for the GenericValue from the persistent store, looking first in the global generic cache (for the moment this isn't true, is same as EmbeddedCache variant)- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition file- Returns:
- List of GenericValue instances as specified in the relation definition
- Throws:
GenericEntityException
-
getRelatedMulti
public List<GenericValue> getRelatedMulti(String relationNameOne, String relationNameTwo, List<String> orderBy) throws GenericEntityException Get the named Related Entity for the GenericValue from the persistent store across another Relation. Helps to get related Values in a multi-to-multi relationship.- Parameters:
relationNameOne- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition file, for first relationrelationNameTwo- String containing the relation name for second relationorderBy- The fields of the named entity to order the query by; may be null; optionally add a " ASC" for ascending or " DESC" for descending- Returns:
- List of GenericValue instances as specified in the relation definition
- Throws:
GenericEntityException
-
getRelatedMulti
public List<GenericValue> getRelatedMulti(String relationNameOne, String relationNameTwo) throws GenericEntityException Get the named Related Entity for the GenericValue from the persistent store across another Relation. Helps to get related Values in a multi-to-multi relationship.- Parameters:
relationNameOne- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition file, for first relationrelationNameTwo- String containing the relation name for second relation- Returns:
- List of GenericValue instances as specified in the relation definition
- Throws:
GenericEntityException
-
getRelatedCache
public List<GenericValue> getRelatedCache(String relationName, Map<String, ?> byAndFields, List<String> orderBy) throws GenericEntityExceptionGet the named Related Entity for the GenericValue from the persistent store, looking first in the global generic cache (for the moment this isn't true, is same as EmbeddedCache variant)- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition filebyAndFields- the fields that must equal in order to keep; may be nullorderBy- The fields of the named entity to order the query by; may be null; optionally add a " ASC" for ascending or " DESC" for descending- Returns:
- List of GenericValue instances as specified in the relation definition
- Throws:
GenericEntityException
-
getRelatedEmbeddedCache
public List<GenericValue> getRelatedEmbeddedCache(String relationName) throws GenericEntityException Get the named Related Entity for the GenericValue from the persistent store, looking first in a cache associated with this entity which is destroyed with this ValueObject when no longer used.- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition file- Returns:
- List of GenericValue instances as specified in the relation definition
- Throws:
GenericEntityException
-
getRelatedEmbeddedCache
public List<GenericValue> getRelatedEmbeddedCache(String relationName, Map<String, ?> byAndFields, List<String> orderBy) throws GenericEntityExceptionGet the named Related Entity for the GenericValue from the persistent store, looking first in a cache associated with this entity which is destroyed with this ValueObject when no longer used.- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition filebyAndFields- the fields that must equal in order to keep; may be nullorderBy- The fields of the named entity to order the query by; may be null; optionally add a " ASC" for ascending or " DESC" for descending- Returns:
- List of GenericValue instances as specified in the relation definition
- Throws:
GenericEntityException
-
getRelatedOne
Get the named Related Entity for the GenericValue from the persistent store- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition file- Returns:
- List of GenericValue instances as specified in the relation definition
- Throws:
GenericEntityException
-
getRelatedOneCache
Get the named Related Entity for the GenericValue from the persistent store, looking first in the global generic cache (for the moment this isn't true, is same as EmbeddedCache variant)- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition file- Returns:
- List of GenericValue instances as specified in the relation definition
- Throws:
GenericEntityException
-
getRelatedOneEmbeddedCache
Get the named Related Entity for the GenericValue from the persistent store, looking first in a cache associated with this entity which is destroyed with this ValueObject when no longer used.- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition file- Returns:
- List of GenericValue instances as specified in the relation definition
- Throws:
GenericEntityException
-
getRelatedByAnd
public List<GenericValue> getRelatedByAnd(String relationName, Map<String, ?> fields) throws GenericEntityExceptionGet the named Related Entity for the GenericValue from the persistent store and filter it- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition filefields- the fields that must equal in order to keep- Returns:
- List of GenericValue instances as specified in the relation definition
- Throws:
GenericEntityException
-
getRelatedByAndCache
public List<GenericValue> getRelatedByAndCache(String relationName, Map<String, ?> fields) throws GenericEntityExceptionGet the named Related Entity for the GenericValue from the persistent store and filter it, looking first in the global generic cache (for the moment this isn't true, is same as EmbeddedCache variant)- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition filefields- the fields that must equal in order to keep- Returns:
- List of GenericValue instances as specified in the relation definition
- Throws:
GenericEntityException
-
getRelatedByAndEmbeddedCache
public List<GenericValue> getRelatedByAndEmbeddedCache(String relationName, Map<String, ?> fields) throws GenericEntityExceptionGet the named Related Entity for the GenericValue from the persistent store and filter it, looking first in a cache associated with this entity which is destroyed with this ValueObject when no longer used.- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition filefields- the fields that must equal in order to keep- Returns:
- List of GenericValue instances as specified in the relation definition
- Throws:
GenericEntityException
-
getRelatedOrderBy
public List<GenericValue> getRelatedOrderBy(String relationName, List<String> orderBy) throws GenericEntityException Get the named Related Entity for the GenericValue from the persistent store and order it- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition fileorderBy- the order that they should be returned- Returns:
- List of GenericValue instances as specified in the relation definition
- Throws:
GenericEntityException
-
getRelatedOrderByCache
public List<GenericValue> getRelatedOrderByCache(String relationName, List<String> orderBy) throws GenericEntityException Get the named Related Entity for the GenericValue from the persistent store and order it, looking first in the global generic cache (for the moment this isn't true, is same as EmbeddedCache variant)- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition fileorderBy- the order that they should be returned- Returns:
- List of GenericValue instances as specified in the relation definition
- Throws:
GenericEntityException
-
getRelatedOrderByEmbeddedCache
public List<GenericValue> getRelatedOrderByEmbeddedCache(String relationName, List<String> orderBy) throws GenericEntityException Get the named Related Entity for the GenericValue from the persistent store and order it, looking first in a cache associated with this entity which is destroyed with this ValueObject when no longer used.- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition fileorderBy- the order that they should be returned- Returns:
- List of GenericValue instances as specified in the relation definition
- Throws:
GenericEntityException
-
removeRelated
Remove the named Related Entity for the GenericValue from the persistent store- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition file- Throws:
GenericEntityException
-
getRelatedDummyPK
Get a dummy primary key for the named Related Entity for the GenericValue- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition file- Returns:
- GenericPK containing a possibly incomplete PrimaryKey object representing the related entity or entities
- Throws:
GenericEntityException
-
getRelatedDummyPK
public GenericPK getRelatedDummyPK(String relationName, Map<String, ?> byAndFields) throws GenericEntityExceptionGet a dummy primary key for the named Related Entity for the GenericValue- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition filebyAndFields- the fields that must equal in order to keep; may be null- Returns:
- GenericPK containing a possibly incomplete PrimaryKey object representing the related entity or entities
- Throws:
GenericEntityException
-
clone
Clones this GenericValue, this is a shallow clone & uses the default shallow HashMap clone- Overrides:
clonein classGenericEntity- Returns:
- Object that is a clone of this GenericValue
-
GenericValue(GenericDelegator internalDelegator, ModelEntity modelEntity)