Giter Site home page Giter Site logo

querydsl / querydsl Goto Github PK

View Code? Open in Web Editor NEW
4.6K 158.0 861.0 50.45 MB

Unified Queries for Java

Home Page: https://querydsl.com

License: Apache License 2.0

Ruby 0.01% Puppet 0.02% Clojure 0.03% Shell 0.03% Java 96.15% CSS 0.05% XSLT 0.53% Scala 2.01% Kotlin 1.18%

querydsl's Introduction

Querydsl

Querydsl is a framework which enables the construction of type-safe SQL-like queries for multiple backends including JPA, MongoDB and SQL in Java.

Instead of writing queries as inline strings or externalizing them into XML files they are constructed via a fluent API.

Website shields.io Build Status Coverage Status Stackoverflow Maven Central

Getting started

Use these tutorials to get started

Examples

Querydsl example projects

Support

Free support is provided in the Discussion Section and on StackOverflow. Please do not post questions as issue. Such issues will be closed immediately.

How to build

Querydsl provides releases via public Maven repositories, but you can also build the sources yourself like this

$ mvn -Pquickbuild,{projectname} clean install

Where projectname is one of the Maven profiles (e.g. jpa, sql, mongodb, etc. or all)

For more information visit the project homepage at https://querydsl.github.io.

Docker Compose setup

For running tests, a Docker Compose setup is provided. It comes with the following databases:

  • Oracle Express Edition 11g
  • PostgreSQL 9.1.10
  • MySQL 5.5.34
  • Cubrid 9.2

You will need to install Docker and docker-compose.

To launch the database containers:

$ docker-compose up -d

All of the databases' default ports are forwarded to the host machine.

How to contribute

GitHub pull requests are the way to contribute to Querydsl.

If you are unsure about the details of a contribution, ask on the Querydsl Google Group or create a ticket on GitHub.

Slack

If you want to join Slack workspace for Querydsl contributors join by following this link.

querydsl's People

Contributors

attila-kiss-it avatar balazs-zsoldos avatar bbakerman avatar bcubk avatar capital5 avatar daniel-shuy avatar dependabot-preview[bot] avatar dependabot[bot] avatar dharaburda avatar f43nd1r avatar grimly avatar heesuk-ahn avatar idosal avatar jendap avatar johnktims avatar jtsay362 avatar jwgmeligmeyling avatar khauser avatar lpandzic avatar mcuelenaere avatar mdiazf avatar natros avatar rdicroce avatar rdnetto4 avatar robertandrewbain avatar shredder121 avatar timowest avatar tpuica avatar tuomaskiviaho avatar viniciuspires avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

querydsl's Issues

APT NullPointer when generating query with JPA and Collections common base class

When using the APT-JPA generator in my setup, I get the following exception:

[javac] Note: Running QuerydslAnnotationProcessor
[javac] Note: Serializing Entity types
[javac] Note: Generating apttest.plainschema.QA for [apttest.plainschema.A]
[javac] Note: Generating apttest.QAValueObject for []
[javac] Note: Serializing Embeddable types
[javac] Note: Generating apttest.plainschema.QC for [apttest.plainschema.C]
[javac] An annotation processor threw an uncaught exception.
[javac] Consult the following stack trace for details.
[javac] java.lang.NullPointerException
[javac] at com.mysema.query.codegen.TypeMappings.getQueryType(TypeMappings.java:106)
[javac] at com.mysema.query.codegen.TypeMappings.getPathType(TypeMappings.java:102)
[javac] at com.mysema.query.codegen.TypeMappings.getPathType(TypeMappings.java:98)
[javac] at com.mysema.query.codegen.EntitySerializer.introSuper(EntitySerializer.java:400)
[javac] at com.mysema.query.codegen.EntitySerializer.intro(EntitySerializer.java:232)
[javac] at com.mysema.query.codegen.EntitySerializer.serialize(EntitySerializer.java:542)
[javac] at com.mysema.query.apt.Processor.serialize(Processor.java:681)
[javac] at com.mysema.query.apt.Processor.serializeTypes(Processor.java:190)
[javac] at com.mysema.query.apt.Processor.process(Processor.java:139)
[javac] at com.mysema.query.apt.QuerydslAnnotationProcessor.process(QuerydslAnnotationProcessor.java:51)
[javac] at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:735)
[javac] at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:664)
[javac] at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:809)
[javac] at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1061)
[javac] at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:796)
[javac] at com.sun.tools.javac.main.Main.compile(Main.java:388)
[javac] at com.sun.tools.javac.main.Main.compile(Main.java:308)
[javac] at com.sun.tools.javac.main.Main.compile(Main.java:299)
[javac] at com.sun.tools.javac.Main.compile(Main.java:82)
[javac] at com.sun.tools.javac.Main.main(Main.java:67)

Another Exception is hidden in the example, which can be caused by annotating AValueObject with @QuerySupertype:

[javac] Note: Running QuerydslAnnotationProcessor
[javac] Note: Serializing Supertypes
[javac] Note: Generating apttest.QAValueObject for [apttest.AValueObject]
[javac] Note: Serializing Entity types
[javac] Note: Generating apttest.plainschema.QA for [apttest.plainschema.A]
[javac] Note: Serializing Embeddable types
[javac] Note: Generating apttest.plainschema.QC for [apttest.plainschema.C]
[javac] Note: Generating apttest.plainschema.QB for [apttest.plainschema.B]
[javac] Note: Running JPAAnnotationProcessor
[javac] Note: Serializing Supertypes
[javac] Note: Generating apttest.QAEntity for [apttest.AEntity]
[javac] error: Attempt to reopen a file for path /home/subes/Dokumente/Entwicklung/invesdwin/inv-finanzdaten-workspace/querydsltc/gen/apttest/QAValueObject.java
[javac] Note: Serializing Entity types
[javac] Note: Generating apttest.jpaschema.QA for [apttest.jpaschema.A]
[javac] Note: Generating apttest.jpareal.sub.QAbschlussberichtEntity for [apttest.jpareal.sub.AbschlussberichtEntity]
[javac] Note: Generating apttest.jpareal.QUnternehmenEntity for [apttest.jpareal.UnternehmenEntity]
[javac] Note: Serializing Embeddable types
[javac] Note: Generating apttest.jpaschema.QB for [apttest.jpaschema.B]
[javac] Note: Generating apttest.jpaschema.QC for [apttest.jpaschema.C]
[javac] Note: Generating apttest.jpareal.sub.QAbschlussberichtEntityCashFlowPeriode for [apttest.jpareal.sub.AbschlussberichtEntityCashFlowPeriode]
[javac] Note: Generating apttest.jpareal.sub.QAbschlussberichtEntityIncome for [apttest.jpareal.sub.AbschlussberichtEntityIncome]
[javac] Note: Generating apttest.jpareal.sub.QAbschlussberichtEntityBalanceAktiva for [apttest.jpareal.sub.AbschlussberichtEntityBalanceAktiva]
[javac] Note: Generating apttest.jpareal.sub.QAbschlussberichtEntityBalance for [apttest.jpareal.sub.AbschlussberichtEntityBalance]
[javac] Note: Generating apttest.jpareal.sub.QAbschlussberichtEntityBalancePassiva for [apttest.jpareal.sub.AbschlussberichtEntityBalancePassiva]
[javac] Note: Generating apttest.jpareal.sub.QAbschlussberichtEntityCashFlow for [apttest.jpareal.sub.AbschlussberichtEntityCashFlow]
[javac] Note: Running QuerydslAnnotationProcessor
[javac] Note: Running JPAAnnotationProcessor
[javac] 1 error

See attachment for the example eclipse project which reproduces the problem. Run the ant target "generate" to reproduce the issue.

This is a serious problem which hinders me from integrating querydsl into my platform. Thanks for your help!

Support for populating master beans

Will the following generated bean type

@table("address")
class Address { ... }

class AddressMaster extends Address { ... }

The AddressMaster type should be easily populated :

from(address).innerJoin(address.rows, row) ... grouping ... .as(AddressMaster.class, address, set(row).as("rows"))

How about add setComment(String) to JPAQuery?

Now, we can set a query comment with JPAQuery.setHint("org.hibernate.comment", "hint"). I think, It would be nice to also be able to do something like this:

JPAQuery.setComment("hint');

What do you think about this?

properly exclude @QueryExclude annotated classes

Hi,

when generating a query class for a class that extends a @QueryExclude class, the super statement is still generated for the queryclass which fails to compile because there is no query class for the super class.

Expected behaviour would be that the @QueryExclude works in that case aswell and the super field does not get generated.

See attachment for the sample.

update Apache Commons dependencies

Several third party libraries are out of date. Amongst them:

  • collections-generic-4.01.jar & commons-collections-3.1.jar; replace with Apache Commons

<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>

  • commons-io-1.4.jar; out-of-date, update to 2.1

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.1</version>
</dependency>

  • commons-lang-2.4.jar; out-of-date, update to 3.0.1

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.0.1</version>
</dependency>

Make AnnotationProcessorMojo thread-safe to support Maven 3 parallel builds

The AnnotationProcessorMojo seems to be not thread-safe, i.e. when using Maven 3 parallel builds (see https://cwiki.apache.org/confluence/display/MAVEN/Parallel+builds+in+Maven+3) to build multiple projects using the maven-apt-plugin it most likely fails due to some race conditions.

Attached is a patch with a very simple solution to make it thread-safe so that it can be used in Maven 3 parallel builds. Note that the @threadsafe annotation does not prevent the warning printed out during a parallel build, probably because the AnnotationProcessorMojo is built as a Maven 2 plugin. Even though the warning is still there, the plugin execution is threadsafe.

Mapping for sqlinsertclause based upon annotations

Currenty, the populate method of the sqlinsertclause makes mappings based upon bean property names.
If there would be a possibility to do the mapping based upon property annotations, then the bean property names and the physical table field names don't need to match. This gives extra flexibility.

A suggested system would be to have some kind of "Mapper" system that lets you map between bean properties and the physical fields with custom mapping if required, and one implementation that is based upon annotations

SQLInsertClause.populate(Object aBean, BeanMapper aBeanMapper)

Where you have ...

PropertyBasedBeanMapper
AnnotationBasedBeanMapper
MyCustomCodedBeanMapper

This would give most flexibility.

https://groups.google.com/forum/#!topic/querydsl/UNU34YPsmZw

Fix escaping of default variable name

Classes like the following cause problems

class Person {
  Person person;
  Person person1;
}

if the person1 property is evaluated before person, person1 is used as the default variable, which is already claimed by the property field.

@QueryInit seems broken in QueryDSL 2.2.3

Hi,
i got quite a bit problem doing deep searches with querydsl, i.e. something like :

QCustomer.address.city.zipcode.eq("1234");

I always get NPE, because city.zipcode is null.

From what i read about the QueryInit annotation i could specify the paths i'm querying, but this does not seem to solve my problem.
I did try:

  • "city.zipcode" in Customer
  • "*" in Customer
  • "*" along all the chain

All seem not to work, the zipcode field is always null.

From some old Bugreport i saw a small example which does show the same result:

package com.retail_sc.fabrica.querydsl;

import java.util.List;
import java.util.Map;

import com.mysema.query.annotations.QueryEntity;
import com.mysema.query.annotations.QueryInit;

@QueryEntity
@javax.persistence.Entity
public class Entity{

    @QueryInit("*")
    Entity prop1;

    @QueryInit("*")
    Entity prop2;

    List<Entity> entityList;

    Map<String,Entity> entityMap;
}
package com.retail_sc.fabrica.querydsl;

import static org.junit.Assert.assertEquals;

import org.junit.Test;


public class QuerydslConfigTest {

    @Test
    public void test(){
        assertEquals("entity.prop1.prop2.prop1", QEntity.entity.prop1.prop2.prop1.toString());
    }

}

here the NPE will come along the path.

Interestingly, the @QuerydslConfig annotation used before (and which is still documented in http://www.querydsl.com/static/querydsl/2.2.3/reference/html/ch03s02.html) does not seem to exist anymore.

How and where to specify the correct query path ?

Allow functional operations where they make sense

From what I understand, Querydsl is much more about querying than it is about applying arbitrary transformations as part of a query.

If Querydsl supported a few simple functional programming idioms, it could allow us, for example, to specify a transformation that we want applied to each element returned by the query. This transformation could be wrapped inside a functor (a function object). We say that we map such a functor onto each element of the result set, expecting this functor to be called on each result.

A very basic example, with imaginary syntax because I don't want to spend the time writing it more thoroughly :

List firstNames = ["Daniel", "Renee", "Caleb"];

Function addLastNameJomphe = new Function {
@OverRide public String apply(String from) {
return from + " Jomphe";
}
}

With this, if we call...

map(addLastName, firstNames);

...we get this result :

["Daniel Jomphe", "Renee Jomphe", "Caleb Jomphe"]

So map() called addLastName.apply() on each element, building its results using addLastName's operation on the initial elements of the List.

Now, we might prefer to have the last name be customizable on the call site, by instead defining the functor as such :

public class AppendFunction extends Function {
private String toAppend;

  public void Function(String toAppend) { //constructor
      this.toAppend= toAppend;
  }

  @Override public String apply(String from) {
      return from + toAppend;
  }

}

And now, we can map it this way...

map(new AppendFunction(" Jomphe"), firstNames);

...getting this result :

["Daniel Jomphe", "Renee Jomphe", "Caleb Jomphe"]

Now, let's say we're not sure if each element needs a middle space. We wouldn't want to invariably add a middle space if the first name, for some reason, already ended with a space. Let's define a simple utility function :

Function makeSureItEndsWithOneSpace = new Function {
@OverRide public String apply(String from) {
return StringUtils.... // details spared
}
};

With this and a compose operation, we could get the compound result of calling both functions, in turn, on each one of the elements of the List...

map(compose(makeSureItEndsWithOneSpace,
new AppendFunction("Jomphe")),
firstNames);

Such functional operators (map, filter, reduce, compose etc.) and data types (Function) would be very easy to program by yourselves. You may take a look at Google Guava's code, for an example. Or you may even simply package Querydsl with new functions that interop well with Guava's functional operators and data types, since Guava, nowadays, has become almost as much ubiquitous as Java itself, in Java projects.

I'm asking for this because when I found Querydsl, I was researching all the Java libraries that bring such useful idioms in our tool set. When I tried Querydsl, I became surprised how it didn't reach into this kind of potential, meaning that it becomes much less useful to our potential needs, unless we couple it with something like Guava.

That said, to see how Querydsl could multiply its potential, I suggest you take a look at LambdaJ, which also does querying, grouping, and etc., but doesn't stop there. (Thanks to its use of APT, Querydsl could probably do the same as LambdaJ, but with better overall performance.)

SQL : Stored procedure support

Stored procedure support

Pseudocode

CREATE OR REPLACE PROCEDURE order_update (id INTEGER, customer_id INTEGER, amount OUT DECIMAL);

OrderUpdate orderUpdate = new OrderUpdate(configuration, connection);
// OrderUpdate is generated based on a stored procedure with the same name
orderUpdate.setId(123);
orderUpdate.setCustomerId(7849320);
orderUpdate.execute();
Double amount = orderUpdate.getAmount();

NPE in APT Plugin (Processor.processEmbedded(..))

When generating the query types using the Maven APT plugin, I get a NPE when processing an embedded entity in combination with generics (see stack trace below).

I have the following abstract base entity class:

@MappedSuperclass
public abstract class AbstractEntity<C extends EntityCode> implements Entity<AbstractEntity> {

    /**
     * The code of the entity, never null and unique per typed entity.
     */
    @Embedded
    @Column(name = "code", nullable = false, unique = true)
    protected C code;
}

The abstract base entity class has a member of type EntityCode, which is a base class for all different types of entity codes and is embeddable:

@MappedSuperclass
public class EntityCode implements ValueObject<EntityCode> {

    @Column(name = "code", unique = true)
    private String code;

    // Default no-arg constructor needed for JPA
    protected EntityCode() {
    }

    public EntityCode(String code) {
        Validate.notNull(code, "code is null");
        this.code = code;
    }
}

Now when generating the query type for an entity class that extends the base entity AbstractEntity, I get the following NPE:

An annotation processor threw an uncaught exception.
Consult the following stack trace for details.
java.lang.NullPointerException
    at com.mysema.query.apt.Processor.processEmbedded(Processor.java:641)
    at com.mysema.query.apt.Processor.processAnnotations(Processor.java:161)
    at com.mysema.query.apt.Processor.process(Processor.java:128)
    at com.mysema.query.apt.jpa.JPAAnnotationProcessor.process(JPAAnnotationProcessor.java:48)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:625)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:554)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:699)
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:981)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)
    at com.sun.tools.javac.main.Main.compile(Main.java:353)
    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:115)
    at com.mysema.maven.apt.AbstractProcessorMojo.execute(AbstractProcessorMojo.java:210)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Could somebody please investigate this issue? Please let me know if you need anything else or whether I can be of any assistance.

Cheers,
Pepijn

QueryDSL annotation processor fails in eclipse 3.6

QueryDSL annotation processor fails in eclipse 3.6 with error:

java.lang.NullPointerException
    at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundEnvImpl.getElementsAnnotatedWith(RoundEnvImpl.java:122)
    at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundEnvImpl.getElementsAnnotatedWith(RoundEnvImpl.java:186)
    at com.mysema.query.apt.Processor.processExclusions(Processor.java:187)
    at com.mysema.query.apt.Processor.processAnnotations(Processor.java:146)
    at com.mysema.query.apt.Processor.process(Processor.java:127)
    at com.mysema.query.apt.jpa.JPAAnnotationProcessor.process(JPAAnnotationProcessor.java:48)
    at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.handleProcessor(RoundDispatcher.java:139)
    at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.round(RoundDispatcher.java:121)
    at org.eclipse.jdt.internal.compiler.apt.dispatch.BaseAnnotationProcessorManager.processAnnotations(BaseAnnotationProcessorManager.java:159)
    at org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager.processAnnotations(IdeAnnotationProcessorManager.java:134)
    at org.eclipse.jdt.internal.compiler.Compiler.processAnnotations(Compiler.java:809)
    at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:428)
    at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:364)
    at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.compile(BatchImageBuilder.java:178)
    at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:301)
    at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.java:60)
    at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:254)
    at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:173)
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:629)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:172)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:203)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:255)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:258)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:311)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:343)
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:144)
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:242)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

At the same time the processor from 2.2.0 works fine.

request for change "IllegalArgumentException: eq(null) is not allowed. Use isNull() instead"

When using com.mysema.query.types.expr.SimpleExpression.eq(Expression<? super T> right) where right is set to null an IllegalArgumentException is thrown:

java.lang.IllegalArgumentException: eq(null) is not allowed. Use isNull() instead

This is by design (see https://bugs.launchpad.net/querydsl/+bug/720078) however it would be better to check if right is null and use isNull() accordingly. e.g.

public BooleanExpression eq(T right) {
    return right == null ? isNull() : eq(new ConstantImpl<T>(right));
}

see SimpleExpression.java:124

At the moment I have to do this null checking in my code every time I want to use .eq(...). This is cumbersome which defeats the purpose of Querydsl's fluent design.

SQL : Merge query support

Provide a merge query that will work on DBMSs that do not support merge. It would work by using the data entered into the columns() and values() methods to generate a where clause automatically. An ID would be entered in the key() method and that data would be used to generate the Querydsl list() request. When a list of IDs is returned that list would be used to generate an update statement. The values that are not in the list of IDs would be used to generate an insert statement. The whole operation would return a unified list of IDs from the update command and the insert command. Many times, a merge command is used to insert or update a single record so it is mostly a convenience to write the lookup and update in one command.
http://www.h2database.com/html/grammar.html#merge

maven-apt-plugin fails to configure lifecylce for m2eclipse 0.13.x

When i try to import a query-dsl test project i'm getting the following error:

Plugin execution not covered by lifecycle configuration: com.mysema.maven:maven-apt-plugin:1.0:process (execution:
default, phase: generate-sources)

The result is, i'm not getting the generated-sources directory in eclipse anymore. Is it possible to use the standard jdk 1.6 apt processor for querydsl ?

Support for results transformer (e.g. group by)

There should be an easy way of defining (generic) transformers over a whole result set. For example to group results by.

Usage scenario:

Query qry=...;
qry.from(post).innerJoin(post.comments, comment);
...
Collection<Group> groups = qry.transform(new GroupByTransformer(post.id, post.name, comment.id);

for (Group group : groups) {
    Long id = group.get(post.id);
    String name = group.get(post.name);
    List<Long> commentIds = group.getList(comment.id);
    ...
}

Under the hood this boils down to ResultTransformer interface that functions as a callback that gets a Projectable and returns the digested results:

public interface ResultTransformer<T> {

    T transform(Projectable projectable);
}

NPE in AbstractSQLQuery when no connection provided

If I create an SQLQuery without a connection like this

SQLQuery query = new SQLQueryImpl(new PostgresTemplates());

and later forget to clone with a connection I get and NPE when calling uniqueResults. Could you add a null check and throw a more informative exception alerting the user to the problem.

The exception I see is:
Exception in thread "main" java.lang.NullPointerException
at com.mysema.query.sql.AbstractSQLQuery.iterateSingle(AbstractSQLQuery.java:434)
at com.mysema.query.sql.AbstractSQLQuery.iterate(AbstractSQLQuery.java:367)
at com.mysema.query.sql.AbstractSQLQuery.iterate(AbstractSQLQuery.java:360)
at com.mysema.query.sql.AbstractSQLQuery.uniqueResult(AbstractSQLQuery.java:576)
...

ElementCollection with non EntityReturn type results in missing enteries in QueryType

ElementCollection such as

@ElementCollection(targetClass = BookMarkImpl.class)
@CollectionTable(
        name = "book_bookmarks"

)
@OrderColumn()
public List<BookMark> getBookMarks() {
    return bookMarks;
}

results in QBookDefinition containing

ListPath<BookMark, SimplePath<BookMark>>

Where as

@ElementCollection(targetClass = BookMarkImpl.class)
@CollectionTable(
        name = "book_bookmarks"

)
@OrderColumn()
public List<BookMarkImpl> getBookMarks2() {
    return bookMarks2;
}

public void setBookMarks2(List<BookMarkImpl> bookMarks) {
    this.bookMarks2 = bookMarks;
}

generates

public final ListPath<BookMarkImpl, QBookMarkImpl> bookMarks2

QueryInit compile time check

Since @QueryInit refers to properties using strings, there's a risk of typos and breaking due to refactoring.

APT processor could verify QueryInits so that they actually match some properties and raise an error if not. This would bring at least some of the benefits of static typing into QueryInits.

querydsl "export" should avoid updating files if possible

I am using the "export" goal of querydsl-maven-plugin to generate query classes. Unfortunately, each time querydsl touches files, it causes Maven to rebuild a JAR file for the project. Then, anything that depends on that project ends up rebuilding as well.

querydsl should avoid updating query files if they have not been changed. Doing so, would substantially speed up my builds.

Map entity property throws a NPE

I have the following entity classes, beside a couple of other (so far non critical).

@Entity(value = "USER", noClassnameStored = true)
public class User implements IUser, UserDetails, Account {
    ....
    @Embedded
    private Map<String, UserAttribute> properties;
    ....
    //usual getter an setters

}

@Embedded
public class UserAttribute implements IAttribute {

    //simple property values (String, Object or Date)
}

When i generate the sources with mvn i run into:

An annotation processor threw an uncaught exception.
Consult the following stack trace for details.
java.lang.NullPointerException
at com.mysema.query.apt.ExtendedTypeFactory.createMapType(ExtendedTypeFactory.java:234)
at com.mysema.query.apt.ExtendedTypeFactory.createInterfaceType(ExtendedTypeFactory.java:366)
at com.mysema.query.apt.ExtendedTypeFactory.handleDeclaredType(ExtendedTypeFactory.java:462)
at com.mysema.query.apt.ExtendedTypeFactory.handle(ExtendedTypeFactory.java:441)
at com.mysema.query.apt.ExtendedTypeFactory.createType(ExtendedTypeFactory.java:158)
at com.mysema.query.apt.ExtendedTypeFactory.getType(ExtendedTypeFactory.java:151)
at com.mysema.query.apt.ElementHandler.handleMethodProperty(ElementHandler.java:182)
at com.mysema.query.apt.ElementHandler.handleEntityType(ElementHandler.java:104)
at com.mysema.query.apt.Processor.process(Processor.java:467)
at com.mysema.query.apt.Processor.processEntities(Processor.java:669)
at com.mysema.query.apt.Processor.processAnnotations(Processor.java:181)
at com.mysema.query.apt.Processor.process(Processor.java:127)
at com.mysema.query.mongodb.morphia.MorphiaAnnotationProcessor.process(MorphiaAnnotationProcessor.java:
54)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.j
ava:625)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnviron
ment.java:554)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.ja
va:699)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:981)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)
at com.sun.tools.javac.main.Main.compile(Main.java:353)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:115)
at com.mysema.maven.apt.AbstractProcessorMojo.execute(AbstractProcessorMojo.java:210)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:105)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:577)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:324)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:247)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:104)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:427)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:157)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

Excluding the above user class by removing the entity annotation
leads to a successful source generation.

version apt 1.0.2, version dsl 2.2.2

Any ideas? I tried playing with

<querydsl.mapAccessors>false</querydsl.mapAccessors>

and
<querydsl.mapAccessors>true</querydsl.mapAccessors>

but this seems to have no effect, even omitting the option completely
yields the same error result.

Unclear documentation for Projectable.uniqueResult()

The Javadoc reads: "There is some ambiguity for missing results and null valued results, " ... so far so good. It then continues: "for disambiguation and your own projection methods." This part of the sentence makes no sense. What are we supposed to do for disambiguation?

MongodbSerializer.asDBObject(…) should be pluggable

Currently MongodbSerializer does not handle complex objects bound to path expressions as it simply puts them into a BasicDBObject as is although they need to be serialized into a DBObject in turn. So it would be cool if the asDBObject(…) method would either be protected to allow subclasses to customize that behaviour or if MongodbSerializer could simply get a pluggable Transformer<Object, DBObject> to allow delegating customization.

Improve "Undeclared Path X" error message

I've recently started seeing "Undeclared Path X" error messages when issuing queries. I eventually tracked it down to the fact that I was referencing an SQL variable in my query that was not being passed into the SQLQueryImpl constructor.

I found the error message to be confusing. I suggest providing more information about what is actually wrong, such as:

Query refers to undeclared variable "X". Please declare it in the SQLQueryImpl constructor.
  1. The variable name should be quoted, to make it obvious we're talking about a user-declared variable
  2. The error message should suggest how to fix the problem.

SubQuery problem

Hi everybody!!

I am new to QueryDSL, and i have a question about how to use subquerys:

Here my code:

    QReposicion qreposicion = QReposicion.reposicion;
    QEstadoReposicion qestadoreposicion = QEstadoReposicion.estadoReposicion;  
    QEstadoReposicion otraRepo = new QEstadoReposicion("otraRepo"); 

    JPQLQuery query = from(qestadoreposicion).leftJoin(qestadoreposicion.reposicion, qreposicion);
    query.where(qreposicion.impresora.id.eq(idImp));

    query.where(qestadoreposicion.fechaReposicion.in(new HibernateSubQuery().from(otraRepo).
                    groupBy(otraRepo.reposicion.id).
                    having(otraRepo.reposicion.id.eq(qestadoreposicion.reposicion.id)).
                    list(otraRepo.fechaReposicion.max())));
      return query.list(qestadoreposicion);

My problem is:

Caused by: java.lang.IllegalArgumentException: Undeclared path otraRepo
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:48)
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:10)
at com.mysema.query.types.path.NumberPath.accept(NumberPath.java:45)
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:101)
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:61)
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:10)
at com.mysema.query.types.query.ListSubQuery.accept(ListSubQuery.java:60)
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:101)
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:36)
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:10)
at com.mysema.query.types.expr.BooleanOperation.accept(BooleanOperation.java:44)
at com.mysema.query.DefaultQueryMetadata.validate(DefaultQueryMetadata.java:298)
at com.mysema.query.DefaultQueryMetadata.addWhere(DefaultQueryMetadata.java:140)
at com.mysema.query.support.QueryMixin.where(QueryMixin.java:375)
at com.mysema.query.support.QueryBase.where(QueryBase.java:44)
at com.mysema.query.jpa.impl.JPAQuery.where(JPAQuery.java:22)
at es.esoj.printSoft.modelodatos.repository.impl.RepositorioEstadosReposicionImpl.obtenerReposiciones(RepositorioEstadosReposicionImpl.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155)
... 52 more

Why undeclared path 'otraRepo'?

Thanks in advance

QuerDsl: 2.2.3
SpringData-jpa: 1.0.1
Spring.3.0.6

QBean doesn't work with superclass' fields

If i create a QBean using new QBean(myType, true, Map<String, ? extends Expression<?>> bindings);, it doesn't see the fields of the superclass of myType.
The prblem is in initFields():

Class beanType = type;
while (!beanType.equals(Object.class)){
    try {
       Field field = type.getDeclaredField(property);  // Should be "Field field = beanType..."
       ...
    } catch (NoSuchFieldException e) {
        beanType = beanType.getSuperclass();
    }
}

Add support for table-valued functions

Some database systems provide user defined functions that return table values. Those table values can be joined with other relational objects like tables or views. The main advantage is the possibility to make use of parameters in those user defined functions.

An exemplary implementation of this kind of user defined functions is Microsoft SQL Server's Table-Valued User-Defined Function (see http://msdn.microsoft.com/en-us/library/ms191165.aspx). Querydsl support would be a great benefit.

Maybe, Querydsl's RelationalPath can be extended in a way that supports parameters and allow the generation of SQL like select * from Table t join TableValuedFunction(?, ...) tvf on tvf.value=t.value.

Support for UDTs (user defined types)

any databases have implemented a way of defining UDTs (User Defined Types). JDBC support for UDTs is very poor, and many other frameworks completely ignore UDTs. Let's say, T_AUTHOR holds a UDT field ADDRESS of type U_ADDRESS_TYPE, with some nested UDT fields.

-- This example code can be used in the Postgres RDBMS:

CREATE TYPE u_country AS ENUM ('Brazil', 'England', 'Germany')

CREATE TYPE u_street_type AS (
  street VARCHAR(100),
  number VARCHAR(30)
)

CREATE TYPE u_address_type AS (
  street u_street_type,
  zip VARCHAR(50),
  city VARCHAR(50),
  country u_country,
  since DATE,
  code INTEGER
)

Provide m2e connector to let APT plugin work in Eclipse with latest m2eclipse

The latest m2e does not automatically execute build plugins that generate sources by default. Thus when upgrading an Eclipse instance to the latest m2e projects using the APT plugin will not get the generated classes listed as sources anymore.

To get that working again one has to provide additional metadata as an m2e extension as described here. I don't think it's necessary to build and host the plugin yourself but maybe simply provide the necessary meta-info to the Sonatype guys.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.