我们目前基于命名查询返回的两个字段手动构建映射,因为JPA仅提供getResultList().
@NamedQuery{name="myQuery",query="select c.name, c.number from Client c"}
HashMap<Long,String> myMap = new HashMap<Long,String>();
for(Client c: em.createNamedQuery("myQuery").getResultList() ){
myMap.put(c.getNumber, c.getName);
}
Run Code Online (Sandbox Code Playgroud)
但是我觉得自定义映射器或者类似物会更高效,因为这个列表很容易就会产生30,000多个结果.
任何想法,无需手动迭代即可构建Map.
(我使用的是OpenJPA,而不是休眠)
我们需要将查询号附加到应用程序执行的每个查询中.
EX:SELECT*FROM ... WHERE ... QUERYNO 123456 ;
OpenJPA支持查询提示,但仅针对特定实现的特定提示.
...
Query q = em.createQuery("select m from Magazine m where ... ");
q.setHint("openjpa.hint.OptimizeResultCount", new Integer(2));
q.setHint("openjpa.FetchPlan.ReadLockMode","WRITE");
List r = q.getResultList();
...
Run Code Online (Sandbox Code Playgroud)
但是根据JPA规范和openjpa" 忽略了无法由特定数据库处理的无效提示或提示.否则,无效提示将导致抛出ArgumentException." 因此,将"QUERYNO"指定为提示似乎没有任何影响.
如何创建自定义查询提示以在运行时指定?
...查询q = em.createQuery("从杂志m中选择m ......"); q.setHint(" com.me.CustomQueryNoHint ",new Integer(2234)); 列表r = q.getResultList(); ...
基于文档和邮件线程,我已经看到了将maven项目注入我的mojo的3种方法:
/**
* Project instance
*
* @parameter default-value="${project}"
* @required
* @readonly
*/
private MavenProject project;
@Component
private MavenProject project;
@Parameter( expression = "${project}" )
private MavenProject project;
Run Code Online (Sandbox Code Playgroud)
但无论我选择哪一个,当我根据我在maven docs中找到的示例运行单元测试时,project始终为null.
public void testMojoGoal() throws Exception {
File testPom = new File(getBasedir(),
"src/test/resources/unit/basic-test/sample-sh-project-config.xml");
ShunitResourcesMojo mojo = (ShunitResourcesMojo) lookupMojo("prepare",testPom);
assertNotNull(mojo);
mojo.execute();
}
Run Code Online (Sandbox Code Playgroud)
mojo执行包含(并失败)
Validate.notNull(project);
Run Code Online (Sandbox Code Playgroud) Maven install 知道构建生成的所有工件,并将它们推送到本地。
将项目的主要工件以及生命周期中其他插件附加的任何其他工件安装到本地存储库。
帮助插件可能支持这个,但不确定正确的表达
# has all the pieces (artifact, version, type) but is it fair to assume filename will always be that combo?
mvn help:evaluate -Dexpression=project.artifact
Run Code Online (Sandbox Code Playgroud)
有什么方法可以从 Maven 命令获取路径列表吗?
我想生成一个特定工件的列表,以在构建过程中作为工件结果保留下来,而无需发布到 Maven 存储库。
我已经安装了Pivotal的Ops Manager.当我试图指出波什对它的导演我得到:
$ bosh target 10.120.7.11
Target set to 'p-bosh'
Invalid SSL Cert. Use --ca-cert option when setting target to specify SSL certificate
Run Code Online (Sandbox Code Playgroud)
证书是由安装自动生成的.如何通过此错误?
我正在尝试在 Maven 和 Java 项目中使用 Selenium 和 PhantomJS。
以下是我在 pom.xml 文件中使用的依赖项:
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server-standalone</artifactId>
<version>2.53.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>1.4.5</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>jenkins-releases</id>
<url>http://repo.jenkins-ci.org/releases/</url>
</repository>
</repositories>`
Run Code Online (Sandbox Code Playgroud)
在我的 Java 文件中,我尝试使用以下方法设置 PhantomJS 驱动程序,而我的计算机上没有 JAR 文件:
public void set_up(){
PhantomJsDriverManager.getInstance().setup();
// Configuration du driver
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setJavascriptEnabled(true);
driver = new PhantomJSDriver(capabilities);
}
Run Code Online (Sandbox Code Playgroud)
当我第一次尝试这个时,它运行良好,但一两个星期后,我收到了这个错误:
public void set_up(){
PhantomJsDriverManager.getInstance().setup();
// Configuration du driver
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setJavascriptEnabled(true);
driver = …Run Code Online (Sandbox Code Playgroud)