javax.jdo.Query.declareImports()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(14.5k)|赞(0)|评价(0)|浏览(130)

本文整理了Java中javax.jdo.Query.declareImports方法的一些代码示例,展示了Query.declareImports的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.declareImports方法的具体详情如下:
包路径:javax.jdo.Query
类名称:Query
方法名:declareImports

Query.declareImports介绍

[英]Set the import statements to be used to identify the fully qualified name of variables or parameters. Parameters and unbound variables might come from a different class from the candidate class, and the names need to be declared in an import statement to eliminate ambiguity. Import statements are specified as a String with semicolon-separated statements.

The String parameter to this method follows the syntax of the import statement of the Java language.
[中]设置用于标识变量或参数的完全限定名称的导入语句。参数和未绑定变量可能来自与候选类不同的类,需要在import语句中声明名称以消除歧义。导入语句被指定为String,语句之间用分号分隔。
此方法的String参数遵循Java语言的import语句的语法。

代码示例

代码示例来源:origin: apache/hive

String queryFilterString = makeQueryFilterString(catName, dbName, null, filter, params);
query = pm.newQuery(MTable.class);
query.declareImports("import java.lang.String");
query.setResult("tableName");
query.setResultClass(java.lang.String.class);

代码示例来源:origin: org.apache.maven.continuum/continuum-store

public List<BuildResult> getAllBuildsForAProjectByDate( int projectId )
{
  PersistenceManager pm = getPersistenceManager();
  Transaction tx = pm.currentTransaction();
  try
  {
    tx.begin();
    Query query = pm.newQuery( "SELECT FROM " + BuildResult.class.getName() +
      " WHERE project.id == projectId PARAMETERS int projectId ORDER BY endTime DESC" );
    query.declareImports( "import java.lang.Integer" );
    query.declareParameters( "Integer projectId" );
    List result = (List) query.execute( new Integer( projectId ) );
    result = (List) pm.detachCopyAll( result );
    tx.commit();
    return result;
  }
  finally
  {
    rollback( tx );
  }
}

代码示例来源:origin: org.apache.continuum/continuum-store

public LocalRepository getLocalRepositoryByName( String name )
  throws ContinuumStoreException
{
  PersistenceManager pm = getPersistenceManager();
  Transaction tx = pm.currentTransaction();
  try
  {
    tx.begin();
    Extent extent = pm.getExtent( LocalRepository.class, true );
    Query query = pm.newQuery( extent );
    query.declareImports( "import java.lang.String" );
    query.declareParameters( "String name" );
    query.setFilter( "this.name == name" );
    Collection result = (Collection) query.execute( name );
    if ( result.size() == 0 )
    {
      tx.commit();
      return null;
    }
    Object object = pm.detachCopy( result.iterator().next() );
    tx.commit();
    return (LocalRepository) object;
  }
  finally
  {
    rollback( tx );
  }
}

代码示例来源:origin: org.apache.continuum/continuum-store

public Profile getProfileByName( String profileName )
  throws ContinuumStoreException
{
  PersistenceManager pm = getPersistenceManager();
  Transaction tx = pm.currentTransaction();
  try
  {
    tx.begin();
    Extent extent = pm.getExtent( Profile.class, true );
    Query query = pm.newQuery( extent );
    query.declareImports( "import java.lang.String" );
    query.declareParameters( "String name" );
    query.setFilter( "this.name == name" );
    Collection result = (Collection) query.execute( profileName );
    if ( result.size() == 0 )
    {
      tx.commit();
      return null;
    }
    Object object = pm.detachCopy( result.iterator().next() );
    tx.commit();
    return (Profile) object;
  }
  finally
  {
    rollback( tx );
  }
}

代码示例来源:origin: org.apache.continuum/continuum-store

public Schedule getScheduleByName( String name )
  throws ContinuumStoreException
{
  PersistenceManager pm = getPersistenceManager();
  Transaction tx = pm.currentTransaction();
  try
  {
    tx.begin();
    Extent extent = pm.getExtent( Schedule.class, true );
    Query query = pm.newQuery( extent );
    query.declareImports( "import java.lang.String" );
    query.declareParameters( "String name" );
    query.setFilter( "this.name == name" );
    Collection result = (Collection) query.execute( name );
    if ( result.size() == 0 )
    {
      tx.commit();
      return null;
    }
    Object object = pm.detachCopy( result.iterator().next() );
    tx.commit();
    return (Schedule) object;
  }
  finally
  {
    rollback( tx );
  }
}

代码示例来源:origin: org.apache.continuum/continuum-store

query.declareImports( "import java.lang.String" );

代码示例来源:origin: org.apache.continuum/continuum-store

public List<BuildResult> getAllBuildsForAProjectByDate( int projectId )
{
  PersistenceManager pm = getPersistenceManager();
  Transaction tx = pm.currentTransaction();
  try
  {
    tx.begin();
    Query query = pm.newQuery( "SELECT FROM " + BuildResult.class.getName() +
                    " WHERE project.id == projectId PARAMETERS int projectId ORDER BY endTime DESC" );
    query.declareImports( "import java.lang.Integer" );
    query.declareParameters( "Integer projectId" );
    List<BuildResult> result = (List<BuildResult>) query.execute( projectId );
    result = (List<BuildResult>) pm.detachCopyAll( result );
    tx.commit();
    return result;
  }
  finally
  {
    rollback( tx );
  }
}

代码示例来源:origin: org.apache.continuum/continuum-store

public BuildDefinitionTemplate getContinuumBuildDefinitionTemplateWithType( String type )
  throws ContinuumStoreException
{
  PersistenceManager pm = getPersistenceManager();
  Transaction tx = pm.currentTransaction();
  try
  {
    tx.begin();
    Extent extent = pm.getExtent( BuildDefinitionTemplate.class, true );
    Query query = pm.newQuery( extent );
    query.declareImports( "import java.lang.String" );
    query.declareParameters( "String type" );
    query.setFilter( "continuumDefault == true && this.type == type" );
    pm.getFetchPlan().addGroup( BUILD_TEMPLATE_BUILD_DEFINITIONS );
    List result = (List) query.execute( type );
    if ( result == null || result.isEmpty() )
    {
      return null;
    }
    return (BuildDefinitionTemplate) pm.detachCopy( result.get( 0 ) );
  }
  finally
  {
    tx.commit();
    rollback( tx );
  }
}

代码示例来源:origin: org.apache.maven.continuum/continuum-store

public BuildDefinitionTemplate getContinuumBuildDefinitionTemplateWithType( String type )
  throws ContinuumStoreException
{
  PersistenceManager pm = getPersistenceManager();
  Transaction tx = pm.currentTransaction();
  try
  {
    tx.begin();
    Extent extent = pm.getExtent( BuildDefinitionTemplate.class, true );
    Query query = pm.newQuery( extent );
    query.declareImports( "import java.lang.String" );
    query.declareParameters( "String type" );
    query.setFilter( "continuumDefault == true && this.type == type" );
    pm.getFetchPlan().addGroup( BUILD_TEMPLATE_BUILD_DEFINITIONS );
    List result = (List) query.execute( type );
    if ( result == null || result.isEmpty() )
    {
      return null;
    }
    return (BuildDefinitionTemplate) pm.detachCopy( result.get( 0 ) );
  }
  finally
  {
    tx.commit();
    rollback( tx );
  }
}

代码示例来源:origin: org.apache.continuum/continuum-store

public List<BuildDefinition> getDefaultBuildDefinitionsForProjectGroup( int projectGroupId )
  throws ContinuumStoreException
{
  PersistenceManager pm = getPersistenceManager();
  Transaction tx = pm.currentTransaction();
  try
  {
    tx.begin();
    Extent extent = pm.getExtent( ProjectGroup.class, true );
    Query query = pm.newQuery( extent );
    query.declareImports( "import " + BuildDefinition.class.getName() );
    query.declareParameters( "int projectGroupId" );
    query.setFilter(
      "this.id == projectGroupId && this.buildDefinitions.contains(buildDef) && buildDef.defaultForProject == true" );
    query.declareVariables( "BuildDefinition buildDef" );
    query.setResult( "buildDef" );
    List<BuildDefinition> result = (List<BuildDefinition>) query.execute( projectGroupId );
    result = (List<BuildDefinition>) pm.detachCopyAll( result );
    tx.commit();
    if ( result != null )
    {
      return result;
    }
  }
  finally
  {
    rollback( tx );
  }
  return new ArrayList<BuildDefinition>();
}

代码示例来源:origin: org.apache.continuum/continuum-store

public List<DirectoryPurgeConfiguration> getDirectoryPurgeConfigurationsByType( String type )
{
  PersistenceManager pm = getPersistenceManager();
  Transaction tx = pm.currentTransaction();
  try
  {
    tx.begin();
    Extent extent = pm.getExtent( DirectoryPurgeConfiguration.class, true );
    Query query = pm.newQuery( extent );
    query.declareImports( "import java.lang.String" );
    query.declareParameters( "String type" );
    query.setFilter( "this.directoryType == type" );
    List result = (List) query.execute( type );
    return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
  }
  finally
  {
    tx.commit();
    rollback( tx );
  }
}

代码示例来源:origin: org.apache.continuum/continuum-store

public List<DistributedDirectoryPurgeConfiguration> getDistributedDirectoryPurgeConfigurationsByType( String type )
{
  PersistenceManager pm = getPersistenceManager();
  Transaction tx = pm.currentTransaction();
  try
  {
    tx.begin();
    Extent extent = pm.getExtent( DistributedDirectoryPurgeConfiguration.class, true );
    Query query = pm.newQuery( extent );
    query.declareImports( "import java.lang.String" );
    query.declareParameters( "String type" );
    query.setFilter( "this.directoryType == type" );
    List result = (List) query.execute( type );
    return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
  }
  finally
  {
    tx.commit();
    rollback( tx );
  }
}

代码示例来源:origin: org.apache.continuum/continuum-store

public List<DirectoryPurgeConfiguration> getDirectoryPurgeConfigurationsByLocation( String location )
{
  PersistenceManager pm = getPersistenceManager();
  Transaction tx = pm.currentTransaction();
  try
  {
    tx.begin();
    Extent extent = pm.getExtent( DirectoryPurgeConfiguration.class, true );
    Query query = pm.newQuery( extent );
    query.declareImports( "import java.lang.String" );
    query.declareParameters( "String location" );
    query.setFilter( "this.location == location" );
    List result = (List) query.execute( location );
    return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
  }
  finally
  {
    tx.commit();
    rollback( tx );
  }
}

代码示例来源:origin: org.apache.continuum/continuum-store

public List<LocalRepository> getLocalRepositoriesByLayout( String layout )
{
  PersistenceManager pm = getPersistenceManager();
  Transaction tx = pm.currentTransaction();
  try
  {
    tx.begin();
    Extent extent = pm.getExtent( LocalRepository.class, true );
    Query query = pm.newQuery( extent );
    query.declareImports( "import java.lang.String" );
    query.declareParameters( "String layout" );
    query.setFilter( "this.layout == layout" );
    List result = (List) query.execute( layout );
    return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
  }
  finally
  {
    tx.commit();
    rollback( tx );
  }
}

代码示例来源:origin: org.codehaus.plexus.security/plexus-security-user-management-provider-jdo

private List findUsers( String searchField, String searchKey, boolean ascendingUsername )
{
  PersistenceManager pm = getPersistenceManager();
  Transaction tx = pm.currentTransaction();
  try
  {
    tx.begin();
    Extent extent = pm.getExtent( JdoUser.class, true );
    Query query = pm.newQuery( extent );
    String ordering = ascendingUsername ? "username ascending" : "username descending";
    query.setOrdering( ordering );
    query.declareImports( "import java.lang.String" );
    query.declareParameters( "String searchKey" );
    query.setFilter( "this." + searchField + ".toLowerCase().indexOf(searchKey.toLowerCase()) > -1" );
    List result = (List) query.execute( searchKey );
    result = (List) pm.detachCopyAll( result );
    tx.commit();
    return result;
  }
  finally
  {
    rollback( tx );
  }
}

代码示例来源:origin: org.apache.archiva.redback/redback-users-jdo

@SuppressWarnings("unchecked")
private List<User> findUsers( String searchField, String searchKey, boolean ascendingUsername )
{
  PersistenceManager pm = getPersistenceManager();
  Transaction tx = pm.currentTransaction();
  try
  {
    tx.begin();
    Extent extent = pm.getExtent( JdoUser.class, true );
    Query query = pm.newQuery( extent );
    String ordering = ascendingUsername ? "username ascending" : "username descending";
    query.setOrdering( ordering );
    query.declareImports( "import java.lang.String" );
    query.declareParameters( "String searchKey" );
    query.setFilter( "this." + searchField + ".toLowerCase().indexOf(searchKey.toLowerCase()) > -1" );
    List<User> result = (List<User>) query.execute( searchKey );
    result = (List<User>) pm.detachCopyAll( result );
    tx.commit();
    return result;
  }
  finally
  {
    rollback( tx );
  }
}

代码示例来源:origin: org.codehaus.redback/redback-users-jdo

@SuppressWarnings("unchecked")
private List<User> findUsers( String searchField, String searchKey, boolean ascendingUsername )
{
  PersistenceManager pm = getPersistenceManager();
  Transaction tx = pm.currentTransaction();
  try
  {
    tx.begin();
    Extent extent = pm.getExtent( JdoUser.class, true );
    Query query = pm.newQuery( extent );
    String ordering = ascendingUsername ? "username ascending" : "username descending";
    query.setOrdering( ordering );
    query.declareImports( "import java.lang.String" );
    query.declareParameters( "String searchKey" );
    query.setFilter( "this." + searchField + ".toLowerCase().indexOf(searchKey.toLowerCase()) > -1" );
    List<User> result = (List<User>) query.execute( searchKey );
    result = (List<User>) pm.detachCopyAll( result );
    tx.commit();
    return result;
  }
  finally
  {
    rollback( tx );
  }
}

代码示例来源:origin: org.apache.continuum/continuum-store

public List<BuildDefinitionTemplate> getBuildDefinitionTemplatesWithType( String type )
  throws ContinuumStoreException
{
  PersistenceManager pm = getPersistenceManager();
  Transaction tx = pm.currentTransaction();
  try
  {
    tx.begin();
    Extent extent = pm.getExtent( BuildDefinitionTemplate.class, true );
    Query query = pm.newQuery( extent );
    query.declareImports( "import java.lang.String" );
    query.declareParameters( "String type" );
    query.setFilter( "this.type == type" );
    pm.getFetchPlan().addGroup( BUILD_TEMPLATE_BUILD_DEFINITIONS );
    List result = (List) query.execute( type );
    return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
  }
  finally
  {
    tx.commit();
    rollback( tx );
  }
}

代码示例来源:origin: org.apache.maven.continuum/continuum-store

public List<BuildDefinitionTemplate> getBuildDefinitionTemplatesWithType( String type )
  throws ContinuumStoreException
{
  PersistenceManager pm = getPersistenceManager();
  Transaction tx = pm.currentTransaction();
  try
  {
    tx.begin();
    Extent extent = pm.getExtent( BuildDefinitionTemplate.class, true );
    Query query = pm.newQuery( extent );
    query.declareImports( "import java.lang.String" );
    query.declareParameters( "String type" );
    query.setFilter( "this.type == type" );
    pm.getFetchPlan().addGroup( BUILD_TEMPLATE_BUILD_DEFINITIONS );
    List result = (List) query.execute( type );
    return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
  }
  finally
  {
    tx.commit();
    rollback( tx );
  }
}

代码示例来源:origin: org.apache.archiva.redback/redback-users-jdo

@SuppressWarnings("unchecked")
public List<User> findUsersByQuery( UserQuery userQuery )
{
  JdoUserQuery uq = (JdoUserQuery) userQuery;
  PersistenceManager pm = getPersistenceManager();
  Transaction tx = pm.currentTransaction();
  try
  {
    tx.begin();
    Extent extent = pm.getExtent( JdoUser.class, true );
    Query query = pm.newQuery( extent );
    String ordering = uq.getOrdering();
    query.setOrdering( ordering );
    query.declareImports( "import java.lang.String" );
    query.declareParameters( uq.getParameters() );
    query.setFilter( uq.getFilter() );
    query.setRange( uq.getFirstResult(),
            uq.getMaxResults() < 0 ? Long.MAX_VALUE : uq.getFirstResult() + uq.getMaxResults() );
    List<User> result = (List<User>) query.executeWithArray( uq.getSearchKeys() );
    result = (List<User>) pm.detachCopyAll( result );
    tx.commit();
    return result;
  }
  finally
  {
    rollback( tx );
  }
}

相关文章