我使用 Query DSL 生成的实体 EntitySerializer 以便使用 QueryDSL(与 SpringData 集成)查询 JPA 实体。
我收到来自客户端的属性名称,我想为可以添加 (AND) 到其他谓词的属性创建谓词。
我不知道如何从 EntitySerializer 获取与我的属性名称匹配的谓词/路径。例如,假设我们有一个 Person 实体(带有自动生成的 QPerson 类),它有一个我想过滤的“name”属性(最后我想创建一个泛型方法)。这是通用方法:
Public Predicat getPredicatByPropertyName(String propertyName) {
QPerson p = QPerson.person;
person.getPredicat(“propertyName”).like(“tom”);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试开发一个自定义的Maven插件,我正在按照这里描述的官方maven文档中的教程:
http://maven.apache.org/guides/plugin/guide-java-plugin-development.html
但是,当我尝试从不同的项目使用我的插件时,我得到以下内容:
Could not find goal 'generateProtoClasses' in plugin com.myComapny.maven.plugin:myCompany-protobuf-plugin:1.0 among available goals -> [Help 1]
Run Code Online (Sandbox Code Playgroud)
这是我的MOJO:
@Mojo(name = "generateProtoClasses", defaultPhase = LifecyclePhase.GENERATE_RESOURCES)
public class CompileProtoClasses extends AbstractMojo {
@Parameter(defaultValue = "mokmok")
private String inputPath;
public void execute() throws MojoExecutionException {
getLog().info("@@@@@@@@@@@@@@@@@@@@@@@");
getLog().info(inputPath);
}
}
Run Code Online (Sandbox Code Playgroud)
这是使用插件的项目的pom.xml文件的片段:
<plugin>
<groupId>com.myCompany.maven.plugin</groupId>
<artifactId>legolas-protobuf-plugin</artifactId>
<version>1.0</version>
<configuration>
<inputPath>yoyo</inputPath>
</configuration>
<executions>
<execution>
<goals>
<goal>generateProtoClasses</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
插件项目的Pom:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myCompany.maven.plugin</groupId>
<artifactId>myCompany-protobuf-plugin</artifactId>
<version>1.0</version>
<packaging>maven-plugin</packaging>
<name>protobuf-plugin Maven Plugin</name>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId> …Run Code Online (Sandbox Code Playgroud) 我已经开始使用 Hibernate Envers 来审计日志记录业务对象。我已阅读文档,并且从我看到的所有示例中,查询是通过修订号完成的。
我想按修订日期查询,即获取在特定日期或日期范围内发生的已审核实体的所有行。我这样的事可能吗?
我的 revinfo 表包含一个时间戳,所以我知道数据在那里。
以下正则表达式模式应用于非常长的字符串(60KB)时,会使java看起来"挂起".
.*\Q|\E.*\Q|\E.*\Q|\E.*bundle.*
Run Code Online (Sandbox Code Playgroud)
我不明白为什么.
我有以下类(它是JPA实体侦听器):
@Service
public class AuditLogListener {
@Autowired
IDomainObjectDAO domainObjectDAO;
@PostLoad
public void saveOldData(DomainObject obj) {
domainObjectDAO.findAll();
System.out.println("after Load");
}
@PreUpdate
public void logChanges(DomainObject obj) {
}
}
Run Code Online (Sandbox Code Playgroud)
domainObjectDAOSpring会识别该字段,并根据日志自动进行连线。
摘录自日志:
[http-8080-1] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Found injected element on class [com.legolas.entityListeners.AuditLogListener]: AutowiredFieldElement for com.legolas.dao.interfaces.IDomainObjectDAO com.legolas.entityListeners.AuditLogListener.domainObjectDAO
[http-8080-1] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'auditLogListener' to allow for resolving potential circular references
[http-8080-1] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Processing injected method of bean 'auditLogListener': AutowiredFieldElement for com.legolas.dao.interfaces.IDomainObjectDAO com.legolas.entityListeners.AuditLogListener.domainObjectDAO
[http-8080-1] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance …Run Code Online (Sandbox Code Playgroud) java ×2
spring ×2
hibernate ×1
jpa ×1
maven ×1
maven-plugin ×1
querydsl ×1
regex ×1
spring-data ×1