Class QueryMetaData

java.lang.Object
org.apache.openjpa.meta.QueryMetaData
All Implemented Interfaces:
Serializable, SourceTracker, Commentable, MetaDataModes
Direct Known Subclasses:
MultiQueryMetaData

public class QueryMetaData extends Object implements MetaDataModes, SourceTracker, Commentable, Serializable
Holds metadata about named queries. Information stored in this instance gets transfered to new Query instances.
Author:
Steve Kim
See Also:
  • Constructor Details

    • QueryMetaData

      protected QueryMetaData(String name, boolean convertPositionalParametersToNamed)
      Construct with the given name.
  • Method Details

    • getName

      public String getName()
      Return the name for this query.
    • getDefiningType

      public Class getDefiningType()
      The class that defines this query, or null if none.
    • setDefiningType

      public void setDefiningType(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 Class getCandidateType()
      The query candidate class, or null if none.
    • setCandidateType

      public void setCandidateType(Class cls)
      The query result class, or null if none.
    • getResultType

      public Class getResultType()
      The query result class, or null if none.
    • setResultType

      public void setResultType(Class cls)
      The query result class, or null if none.
    • getLanguage

      public String getLanguage()
      Return the query language.
    • setLanguage

      public void setLanguage(String language)
      Set the language for this query.
    • getQueryString

      public String getQueryString()
      The full query string, or null if none.
    • setQueryString

      public void setQueryString(String query)
      The full query string, or null if none.
    • getParsedQuery

      public Object getParsedQuery()
      The already parsed form of this query, or null if none. Non string-based query languages such as the Criteria API are not necessarily expressible as a parseable query string, so their compiled form is held here and replayed verbatim instead of being re-parsed from getQueryString().
    • setParsedQuery

      public void setParsedQuery(Object parsed)
      The already parsed form of this query, or null if none.
    • getParsedQueryId

      public String getParsedQueryId()
      The identifier of the parsed form of this query, or null if none. A query of a non string-based language has no query string to be identified by, so the identifier is rendered once, when the query is registered: the parsed form is shared by every replay of the query and rendering it again would read the shared form without holding its lock.
    • setParsedQueryId

      public void setParsedQueryId(String id)
      The identifier of the parsed form of this query, or null if none.
    • getHintKeys

      public String[] getHintKeys()
      Query hints.
    • getHintValues

      public Object[] getHintValues()
      Query hints.
    • addHint

      public void addHint(String key, Object value)
      Add a query hint.
    • getResultSetMappingName

      public String getResultSetMappingName()
    • setResultSetMappingName

      public void setResultSetMappingName(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 specified Query.
    • getMaxResults

      public int getMaxResults()
      Return the max results for this query, or -1 if not set.
    • setMaxResults

      public void setMaxResults(int maxResults)
      Set the max results for this query. -1 means not set.
    • getFlushType

      public int getFlushType()
      Return the flush type for this query, or -1 if not set. This is a FlushBeforeQueries constant from FetchConfiguration.
    • setFlushType

      public void setFlushType(int flushType)
      Set the flush type for this query. This is a FlushBeforeQueries constant from FetchConfiguration.
    • getLockMode

      public String getLockMode()
      Return the lock mode name for this query, or null if not set.
    • setLockMode

      public void setLockMode(String lockMode)
      Set the lock mode name for this query.
    • getSourceMode

      public int getSourceMode()
      The source mode of this query.
    • setSourceMode

      public void setSourceMode(int mode)
      The source mode of this query.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getComments

      public String[] getComments()
      ////////////
      Specified by:
      getComments in interface Commentable
    • setComments

      public void setComments(String[] comments)
      Description copied from interface: Commentable
      Set comments.
      Specified by:
      setComments in interface Commentable
    • getSourceFile

      public File getSourceFile()
      /////////////////////////////
      Specified by:
      getSourceFile in interface SourceTracker
    • getSourceScope

      public Object getSourceScope()
      Description copied from interface: SourceTracker
      Return the domain-dependent scope of this instance within its file.
      Specified by:
      getSourceScope in interface SourceTracker
    • getSourceType

      public int getSourceType()
      Description copied from interface: SourceTracker
      Return the type of source.
      Specified by:
      getSourceType in interface SourceTracker
    • setSource

      public void setSource(File file, Object scope, int srcType, String srcName)
    • getResourceName

      public 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 interface SourceTracker
    • 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 interface SourceTracker
    • 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 interface SourceTracker
    • setColNumber

      public void setColNumber(int colNum)
    • getSourceName

      public String getSourceName()
    • setParamTypes

      public void setParamTypes(OrderedMap<Object,Class<?>> paramTypes)
    • getParamTypes

      public OrderedMap<Object,Class<?>> getParamTypes()
      Returns:
      a map of parameter name to type for this named query or null if this data hasn't been set.