简体   繁体   中英

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. 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. Even at the very beginning, here , QCategory c = QCategory.category; is used without any pointers as to how those Q-prefixed types are resolved. Predictably, when I try to create an object according to that syntax logic, I get "[abc] cannot be resolved to a type". So if someone could shed some light on that "mystical" Qsometype stuff, I'd be very grateful.

Edit: I'm not currently using Maven for my Eclipse setup (the tutorial mentions Maven pom) Is this impossible without using Maven ? I've investigated some more and I understand the Q-classes are auto-generated by QueryDSL and Maven. My project type in Eclipse is dynamic web, and I'm not sure I want to/should convert this to a Maven project. 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. The configuration entry for this is <processor>net.ravendb.querydsl.RavenDBAnnotationProcessor</processor>

This is using QueryDSL to generate the query classes.

The explanation in the docs is:

Please note that plugins section contains net.ravendb.querydsl.RavenDBAnnotationProcessor . As Java does not have LINQ, all definitions of indexes/transformers must be created using strings. Alternatively, you can use the Studio to create indexes/transformers, yet you can also use QueryDSL for strongly-typed querying. In order to use QueryDSL you have to mark your entities with @QueryEntity annotation and enable code generation in pom.xml.

You can generate this manually, see http://www.querydsl.com/static/querydsl/2.7.3/reference/html/ch03s02.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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