Package org.apache.openjpa.meta
Class QueryMetaData
- java.lang.Object
-
- org.apache.openjpa.meta.QueryMetaData
-
- All Implemented Interfaces:
java.io.Serializable
,SourceTracker
,Commentable
,MetaDataModes
- Direct Known Subclasses:
MultiQueryMetaData
public class QueryMetaData extends java.lang.Object implements MetaDataModes, SourceTracker, Commentable, java.io.Serializable
Holds metadata about named queries. Information stored in this instance gets transfered to newQuery
instances.- Author:
- Steve Kim
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.apache.openjpa.lib.xml.Commentable
EMPTY_COMMENTS
-
Fields inherited from interface org.apache.openjpa.meta.MetaDataModes
MODE_ALL, MODE_ANN_MAPPING, MODE_MAPPING, MODE_MAPPING_INIT, MODE_META, MODE_NONE, MODE_QUERY
-
Fields inherited from interface org.apache.openjpa.lib.meta.SourceTracker
SRC_ANNOTATIONS, SRC_OTHER, SRC_XML
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
QueryMetaData(java.lang.String name, boolean convertPositionalParametersToNamed)
Construct with the given name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addHint(java.lang.String key, java.lang.Object value)
Add a query hint.java.lang.Class
getCandidateType()
The query candidate class, or null if none.int
getColNumber()
Return the column number in the line of the file at which this instance was parsed.java.lang.String[]
getComments()
Return comments, or empty array if none.java.lang.Class
getDefiningType()
The class that defines this query, or null if none.java.lang.String[]
getHintKeys()
Query hints.java.lang.Object[]
getHintValues()
Query hints.java.lang.String
getLanguage()
Return the query language.int
getLineNumber()
Return the line number of the file at which this instance was parsed.java.lang.String
getName()
Return the name for this query.OrderedMap<java.lang.Object,java.lang.Class<?>>
getParamTypes()
java.lang.String
getQueryString()
The full query string, or null if none.java.lang.String
getResourceName()
Return the domain-meaningful name of the resource that was loaded from this source.java.lang.String
getResultSetMappingName()
java.lang.Class
getResultType()
The query result class, or null if none.java.io.File
getSourceFile()
Return the file from which this instance was parsed.int
getSourceMode()
The source mode of this query.java.lang.String
getSourceName()
java.lang.Object
getSourceScope()
Return the domain-dependent scope of this instance within its file.int
getSourceType()
Return the type of source.boolean
isReadOnly()
Whether the query has been marked read-only.void
setCandidateType(java.lang.Class cls)
The query result class, or null if none.void
setColNumber(int colNum)
void
setComments(java.lang.String[] comments)
Set comments.void
setDefiningType(java.lang.Class cls)
The class that defines this query, or null if none.void
setFrom(Query query)
Initialize this instance from the values held in the specifiedQuery
.void
setInto(Query query)
Set query template information into the given concrete query instance.void
setLanguage(java.lang.String language)
Set the language for this query.void
setLineNumber(int lineNum)
void
setParamTypes(OrderedMap<java.lang.Object,java.lang.Class<?>> paramTypes)
void
setQueryString(java.lang.String query)
The full query string, or null if none.void
setReadOnly(boolean readOnly)
Whether the query has been marked read-only.void
setResultSetMappingName(java.lang.String setMappingName)
void
setResultType(java.lang.Class cls)
The query result class, or null if none.void
setSource(java.io.File file, java.lang.Object scope, int srcType, java.lang.String srcName)
void
setSourceMode(int mode)
The source mode of this query.java.lang.String
toString()
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Return the name for this query.
-
getDefiningType
public java.lang.Class getDefiningType()
The class that defines this query, or null if none.
-
setDefiningType
public void setDefiningType(java.lang.Class cls)
The class that defines this query, or null if none.
-
isReadOnly
public boolean isReadOnly()
Whether the query has been marked read-only.
-
setReadOnly
public void setReadOnly(boolean readOnly)
Whether the query has been marked read-only.
-
getCandidateType
public java.lang.Class getCandidateType()
The query candidate class, or null if none.
-
setCandidateType
public void setCandidateType(java.lang.Class cls)
The query result class, or null if none.
-
getResultType
public java.lang.Class getResultType()
The query result class, or null if none.
-
setResultType
public void setResultType(java.lang.Class cls)
The query result class, or null if none.
-
getLanguage
public java.lang.String getLanguage()
Return the query language.
-
setLanguage
public void setLanguage(java.lang.String language)
Set the language for this query.
-
getQueryString
public java.lang.String getQueryString()
The full query string, or null if none.
-
setQueryString
public void setQueryString(java.lang.String query)
The full query string, or null if none.
-
getHintKeys
public java.lang.String[] getHintKeys()
Query hints.
-
getHintValues
public java.lang.Object[] getHintValues()
Query hints.
-
addHint
public void addHint(java.lang.String key, java.lang.Object value)
Add a query hint.
-
getResultSetMappingName
public java.lang.String getResultSetMappingName()
-
setResultSetMappingName
public void setResultSetMappingName(java.lang.String setMappingName)
-
setInto
public void setInto(Query query)
Set query template information into the given concrete query instance. However, the language, query string, and candidate class are assumed to be declared in the query instantiation, and hints are not transferred.
-
setFrom
public void setFrom(Query query)
Initialize this instance from the values held in the specifiedQuery
.
-
getSourceMode
public int getSourceMode()
The source mode of this query.
-
setSourceMode
public void setSourceMode(int mode)
The source mode of this query.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getComments
public java.lang.String[] getComments()
Description copied from interface:Commentable
Return comments, or empty array if none.- Specified by:
getComments
in interfaceCommentable
-
setComments
public void setComments(java.lang.String[] comments)
Description copied from interface:Commentable
Set comments.- Specified by:
setComments
in interfaceCommentable
-
getSourceFile
public java.io.File getSourceFile()
Description copied from interface:SourceTracker
Return the file from which this instance was parsed.- Specified by:
getSourceFile
in interfaceSourceTracker
-
getSourceScope
public java.lang.Object getSourceScope()
Description copied from interface:SourceTracker
Return the domain-dependent scope of this instance within its file.- Specified by:
getSourceScope
in interfaceSourceTracker
-
getSourceType
public int getSourceType()
Description copied from interface:SourceTracker
Return the type of source.- Specified by:
getSourceType
in interfaceSourceTracker
-
setSource
public void setSource(java.io.File file, java.lang.Object scope, int srcType, java.lang.String srcName)
-
getResourceName
public java.lang.String getResourceName()
Description copied from interface:SourceTracker
Return the domain-meaningful name of the resource that was loaded from this source. I.e., if we had loaded the source for a Java class, this would return the name of the class.- Specified by:
getResourceName
in interfaceSourceTracker
-
getLineNumber
public int getLineNumber()
Description copied from interface:SourceTracker
Return the line number of the file at which this instance was parsed.- Specified by:
getLineNumber
in interfaceSourceTracker
-
setLineNumber
public void setLineNumber(int lineNum)
-
getColNumber
public int getColNumber()
Description copied from interface:SourceTracker
Return the column number in the line of the file at which this instance was parsed.- Specified by:
getColNumber
in interfaceSourceTracker
-
setColNumber
public void setColNumber(int colNum)
-
getSourceName
public java.lang.String getSourceName()
-
setParamTypes
public void setParamTypes(OrderedMap<java.lang.Object,java.lang.Class<?>> paramTypes)
-
getParamTypes
public OrderedMap<java.lang.Object,java.lang.Class<?>> getParamTypes()
- Returns:
- a map of parameter name to type for this named query or null if this data hasn't been set.
-
-