2016-05-09 12 views
0

Amazon Redshiftを使用するプロジェクトにQueryDSLを追加しようとしています。私はQueryDSLがRedshiftをサポートしているのかどうか分かりません。おそらくここでは間違っています。私は、関連する抜粋下記参照、Qクラスにコンパイルエラーを取得しています:RedDSP設定のQueryDSL

TABLE DDL(赤方偏移)

CREATE TABLE users_follow (
    user_id1 INT8 NOT NULL, 
    user_id2 INT8 NOT NULL, 
    active INT2 NOT NULL, 
    created_at TIMESTAMP NOT NULL, 
    modified_at TIMESTAMP NOT NULL, 
    PRIMARY KEY (user_id1, user_id2), 
    FOREIGN KEY (user_id1) REFERENCES users (id), 
    FOREIGN KEY (user_id2) REFERENCES users (id) 
) 

CREATE TABLE users (
    id INT8 NOT NULL, 
    username VARCHAR(255), 
    PRIMARY KEY (id) 
) 

POMの依存関係(idカラムとバイナリ主キーのusers_followテーブルの欠如を注意してください) SECTION

<dependency> 
     <groupId>com.querydsl</groupId> 
     <artifactId>querydsl-sql</artifactId> 
     <version>4.1.0</version> 
    </dependency> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-log4j12</artifactId> 
     <version>1.6.1</version> 
    </dependency> 
    <dependency> 
     <groupId>com.querydsl</groupId> 
     <artifactId>querydsl-sql-codegen</artifactId> 
     <version>4.1.0</version> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>com.querydsl</groupId> 
     <artifactId>querydsl-sql-spring</artifactId> 
     <version>4.1.0</version> 
    </dependency> 

POM PLUGINSセクション

 <plugin> 
      <groupId>com.querydsl</groupId> 
      <artifactId>querydsl-maven-plugin</artifactId> 
      <version>4.1.0</version> 
      <executions> 
       <execution> 
        <goals> 
         <goal>export</goal> 
        </goals> 
       </execution> 
      </executions> 
      <configuration> 
       <jdbcDriver>com.amazon.redshift.core.jdbc41.PGJDBC41Driver</jdbcDriver> 
       <jdbcUrl>jdbc:redshift://aUrl.com:5439/aSchema</jdbcUrl> 
       <jdbcPassword>aPassword</jdbcPassword> 
       <jdbcUser>aUser</jdbcUser> 
       <packageName>com.myproject.domain</packageName> 
       <targetFolder>${project.basedir}/target/generated-sources/java</targetFolder> 
       <sourceFolder>${project.basedir}/target/generated-sources/java</sourceFolder> 
      </configuration> 
      <dependencies> 
       <dependency> 
        <groupId>com.amazonaws</groupId> 
        <artifactId>redshift</artifactId> 
        <version>${redshift.version}</version> 
       </dependency> 
      </dependencies> 
     </plugin> 

出力からMVNがきれい-Dmaven.test.skip =真-eインストール-X

... 

[INFO] Exported users_follow successfully 

... 

[INFO] ------------------------------------------------------------- 
[ERROR] COMPILATION ERROR : 
[INFO] ------------------------------------------------------------- 
[ERROR] path/target/generated-sources/java/com/myproject/domain/QUsersFollow.java:[43,109] cannot find symbol 
    symbol: variable id 
    location: class com.myproject.domain.QUsersFollow 
[ERROR] path/target/generated-sources/java/com/myproject/domain/QUsersFollow.java:[45,109] cannot find symbol 
    symbol: variable id 
    location: class com.myproject.domain.QUsersFollow 
[INFO] 18 errors 
[INFO] ------------------------------------------------------------- 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 21.210 s 
[INFO] Finished at: 2016-05-09T04:00:53+00:00 
[INFO] Final Memory: 40M/373M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project analytics-service: Compilation failure: Compilation failure: 
[ERROR] path/target/generated-sources/java/com/myproject/domain/QUsersFollow.java:[43,109] cannot find symbol 
[ERROR] symbol: variable id 
[ERROR] location: class com.myproject.domain.QUsersFollow 
[ERROR] path/target/generated-sources/java/com/myproject/domain/QUsersFollow.java:[45,109] cannot find symbol 
[ERROR] symbol: variable id 
[ERROR] -> [Help 1] 
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project analytics-service: Compilation failure 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212) 
    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:116) 
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) 
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) 
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) 
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) 
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) 
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) 
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862) 
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286) 
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:197) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) 
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure 
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:972) 
    at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129) 
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) 
    ... 20 more 

package com.myproject.domain; 

import static com.querydsl.core.types.PathMetadataFactory.*; 

import com.querydsl.core.types.dsl.*; 

import com.querydsl.core.types.PathMetadata; 
import javax.annotation.Generated; 
import com.querydsl.core.types.Path; 

import com.querydsl.sql.ColumnMetadata; 
import java.sql.Types; 

/** 
* QUsersFollow is a Querydsl query type for QUsersFollow 
*/ 
@Generated("com.querydsl.sql.codegen.MetaDataSerializer") 
public class QUsersFollow extends com.querydsl.sql.RelationalPathBase<QUsersFollow> { 

    private static final long serialVersionUID = 463786116; 

    public static final QUsersFollow usersFollow = new QUsersFollow("users_follow"); 

    public final NumberPath<Short> active = createNumber("active", Short.class); 

    public final DateTimePath<java.sql.Timestamp> createdAt = createDateTime("createdAt", java.sql.Timestamp.class); 

    public final DateTimePath<java.sql.Timestamp> modifiedAt = createDateTime("modifiedAt", java.sql.Timestamp.class); 

    public final NumberPath<Long> userId1 = createNumber("userId1", Long.class); 

    public final NumberPath<Long> userId2 = createNumber("userId2", Long.class); 

    public final com.querydsl.sql.PrimaryKey<QUsersFollow> usersFollowNewPkey = createPrimaryKey(userId1, userId2); 

    public final com.querydsl.sql.ForeignKey<QUsers> usersFollowNewUserId1Fkey = createForeignKey(userId1, "id"); 

    public final com.querydsl.sql.ForeignKey<QUsers> usersFollowNewUserId2Fkey = createForeignKey(userId2, "id"); 

    public final com.querydsl.sql.ForeignKey<QUsersFollow> _usersFollowNewUserId1Fkey = createInvForeignKey(id, "user_id1"); //cannot resolve symbol 'id' 

    public final com.querydsl.sql.ForeignKey<QUsersFollow> _usersFollowNewUserId2Fkey = createInvForeignKey(id, "user_id2"); //cannot resolve symbol 'id' 

    public QUsersFollow(String variable) { 
     super(QUsersFollow.class, forVariable(variable), "public", "users_follow"); 
     addMetadata(); 
    } 

    public QUsersFollow(String variable, String schema, String table) { 
     super(QUsersFollow.class, forVariable(variable), schema, table); 
     addMetadata(); 
    } 

    public QUsersFollow(Path<? extends QUsersFollow> path) { 
     super(path.getType(), path.getMetadata(), "public", "users_follow"); 
     addMetadata(); 
    } 

    public QUsersFollow(PathMetadata metadata) { 
     super(QUsersFollow.class, metadata, "public", "users_follow"); 
     addMetadata(); 
    } 

    public void addMetadata() { 
     addMetadata(active, ColumnMetadata.named("active").withIndex(3).ofType(Types.SMALLINT).withSize(5).notNull()); 
     addMetadata(createdAt, ColumnMetadata.named("created_at").withIndex(4).ofType(Types.TIMESTAMP).withSize(29).withDigits(6).notNull()); 
     addMetadata(modifiedAt, ColumnMetadata.named("modified_at").withIndex(5).ofType(Types.TIMESTAMP).withSize(29).withDigits(6).notNull()); 
     addMetadata(userId1, ColumnMetadata.named("user_id1").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); 
     addMetadata(userId2, ColumnMetadata.named("user_id2").withIndex(2).ofType(Types.BIGINT).withSize(19).notNull()); 
    } 

} 
+0

QueryDSL 4.1.0とのPostgresを使用して私のために正常に動作する - それはあなたの問題の根本的な原因である「逆」の外部キーを生成しません。しかし、私はそれを可能にするオプションを見つけることができませんでした。あなたは現在のバージョンを試しましたか?または少なくとも4.0.8? –

+0

@a_horse_with_no_name 4.1.0と試してみると、問題は残ります。 – fred

答えて

1

QueryDSLの開発者をGENERATED QCLASS(記号 'ID' を解決することはできません。注):赤方偏移でサポートされていないDBを、私は、データベースのメタデータがJDBCドライバによって適切に提供されていないと言うでしょう。

https://github.com/querydsl/querydsl/issues/1880