简体   繁体   English

Java中的RavenDB查询别名

[英]RavenDB query alias in Java

I'm sure I'm missing the glaringly obvious, but I can't figure out what the "Q"-prefixed types are supposed to be, or how to resolve them. 我敢肯定我会错过明显的显而易见的信息,但是我无法弄清楚应该以“ Q”为前缀的类型是什么,或者如何解决它们。 Basically, all over the Java documentation, QSomething classes are used, yet I can't find an explanation what they really are, how the prefix works, or how they are resolved. 基本上,在所有Java文档中,都使用QSomething类,但是我找不到解释它们的真正含义,前缀的工作方式或如何解析它们。 Even at the very beginning, here , QCategory c = QCategory.category; 即使在开始时, 这里 QCategory c = QCategory.category; is used without any pointers as to how those Q-prefixed types are resolved. 不用任何指针来解决那些Q前缀类型如何解析。 Predictably, when I try to create an object according to that syntax logic, I get "[abc] cannot be resolved to a type". 可以预见,当我尝试根据该语法逻辑创建对象时,出现“ [abc]无法解析为类型”。 So if someone could shed some light on that "mystical" Qsometype stuff, I'd be very grateful. 因此,如果有人能对“神秘的” Qsometype东西有所了解,我将不胜感激。

Edit: I'm not currently using Maven for my Eclipse setup (the tutorial mentions Maven pom) Is this impossible without using Maven ? 编辑:我当前不在 Eclipse设置中使用Maven(本教程提到Maven pom),如果不使用Maven,这是否不可能? I've investigated some more and I understand the Q-classes are auto-generated by QueryDSL and Maven. 我已经进行了更多研究,并且我知道Q类是由QueryDSL和Maven自动生成的。 My project type in Eclipse is dynamic web, and I'm not sure I want to/should convert this to a Maven project. 我在Eclipse中的项目类型是动态Web,并且不确定是否要/应该将其转换为Maven项目。 In fact, I'm not even sure that would solve my problem. 实际上,我什至不确定这是否可以解决我的问题。

Thanks 谢谢

Those are auto generated classes, if you setup using Maven, it just works. 这些是自动生成的类,如果您使用Maven进行设置,它将可以正常工作。 The configuration entry for this is <processor>net.ravendb.querydsl.RavenDBAnnotationProcessor</processor> 为此的配置条目是<processor>net.ravendb.querydsl.RavenDBAnnotationProcessor</processor>

This is using QueryDSL to generate the query classes. 这是使用QueryDSL生成查询类的。

The explanation in the docs is: 在文档中的解释是:

Please note that plugins section contains net.ravendb.querydsl.RavenDBAnnotationProcessor . 请注意,“插件”部分包含net.ravendb.querydsl.RavenDBAnnotationProcessor As Java does not have LINQ, all definitions of indexes/transformers must be created using strings. 由于Java没有LINQ,因此必须使用字符串创建索引/变压器的所有定义。 Alternatively, you can use the Studio to create indexes/transformers, yet you can also use QueryDSL for strongly-typed querying. 另外,您可以使用Studio创建索引/变压器,但也可以使用QueryDSL进行强类型查询。 In order to use QueryDSL you have to mark your entities with @QueryEntity annotation and enable code generation in pom.xml. 为了使用QueryDSL,您必须使用@QueryEntity批注标记您的实体,并在pom.xml中启用代码生成。

You can generate this manually, see http://www.querydsl.com/static/querydsl/2.7.3/reference/html/ch03s02.html 您可以手动生成此代码,请参见http://www.querydsl.com/static/querydsl/2.7.3/reference/html/ch03s02.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM