ebean-orm-deprecated / ebean-querybean

Moved as a module into ebean.git repo
https://ebean.io/docs/query/query-beans
Apache License 2.0
9 stars 3 forks source link

NullPointerException with querybean #36

Closed thibaultmeyer closed 7 years ago

thibaultmeyer commented 7 years ago

Here the maven project to reproduce issue : https://dl.dropboxusercontent.com/u/37895949/github.com/demo-ebean-query.zip

#> mvn package
#> java -jar target/demo-ebean-1.0.jar
[2016-11-28 13:18:16,976] DEBUG - org.avaje.ebean.SQL (main) - txn[1003] insert into demo_model (name, is_enabled) values (?,?); --bind(Demo,false)
Exception in thread "main" java.lang.NullPointerException
        at MainEntry.main(MainEntry.java:27)

Extract from MainEntry.java

final DemoModel demoModel = new DemoModel();
demoModel.setName("Demo");
demoModel.setEnabled(false);
demoModel.save();

final DemoModel dd = new QDemoModel()
    .isEnabled  // NullPointerException 
    .isTrue()
    .setMaxRows(1)
    .findUnique();

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         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.zero_x_baadf00d</groupId>
    <artifactId>demo-ebean</artifactId>
    <version>1.0</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
            <!-- Java version to use -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <!-- JAR -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <!-- Manifest -->
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>libs/</classpathPrefix>
                            <mainClass>MainEntry</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <!-- Copy dependencies -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.10</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeScope>runtime</includeScope>
                            <outputDirectory>${project.build.directory}/libs/</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- Ebean Agent -->
            <plugin>
                <groupId>org.avaje.ebean</groupId>
                <artifactId>ebean-maven-plugin</artifactId>
                <version>8.2.1</version>
                <executions>
                    <execution>
                        <id>main</id>
                        <phase>process-classes</phase>
                        <configuration>
                            <transformArgs>debug=1</transformArgs>
                        </configuration>
                        <goals>
                            <goal>enhance</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- QueryBean -->
            <plugin>
                <groupId>org.avaje.ebean</groupId>
                <artifactId>querybean-maven-plugin</artifactId>
                <version>8.2.1</version>
                <executions>
                    <!-- enhance code -->
                    <execution>
                        <id>main</id>
                        <phase>process-classes</phase>
                        <configuration>
                            <transformArgs>debug=1</transformArgs>
                        </configuration>
                        <goals>
                            <goal>enhance</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.21</version>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.4.192</version>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.4.1211.jre7</version>
        </dependency>
        <dependency>
            <groupId>org.avaje</groupId>
            <artifactId>avaje-agentloader</artifactId>
            <version>2.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.avaje.ebeanorm</groupId>
            <artifactId>avaje-ebeanorm-agent</artifactId>
            <version>8.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.avaje.ebean</groupId>
            <artifactId>ebean</artifactId>
            <version>9.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.avaje.ebean</groupId>
            <artifactId>querybean-generator</artifactId>
            <version>8.1.4</version>
        </dependency>
        <dependency>
            <groupId>org.avaje.ebean</groupId>
            <artifactId>ebean-querybean</artifactId>
            <version>8.4.1</version>
        </dependency>
        <dependency>
            <groupId>org.avaje.ebean</groupId>
            <artifactId>querybean-agent</artifactId>
            <version>8.2.1</version>
        </dependency>
        <dependency>
            <groupId>org.avaje.ebean</groupId>
            <artifactId>finder-generator</artifactId>
            <version>2.1.3</version>
        </dependency>
    </dependencies>
</project>
rbygrave commented 7 years ago

Ah, I think this should be closed right. You got past this issue ... probably an enhancement issue?