0

このドキュメントを読んで、私は次のようにコードに適用しようとしました。

トリプル

@Entity
@Table(name = "triple")
@NodeEntity
public class TripleDBMoldelNeoImpl implements TripleDBModel{
    protected List<Annotation> annotations;

    @RelatedTo(type = "subject", elementClass = (Class<? extends NodeBacked>) Concept.class) //This is the suggestion Eclipse gives me
    public Concept subject;
    @RelatedTo(type = "object", elementClass = Concept.class)
    public Concept object;
    @RelatedTo(type = "predicate", elementClass = Concept.class)
    public Concept predicate;


    @ManyToMany(
            cascade={CascadeType.ALL }, 
            fetch=FetchType.LAZY
    )   
    @JoinTable(name = "triple_has_annotation", 
            joinColumns={@JoinColumn(name="uri_concept_subject"), @JoinColumn(name="uri_concept_object"), @JoinColumn(name="uri_concept_predicate") },          
            inverseJoinColumns=@JoinColumn(name="annotation_id") )
    public List<Annotation> getAnnotations() {
        return annotations;
    }
    public void setAnnotations(List<Annotation> annotations) {
        this.annotations = annotations;
    }
    @Id 
    @Column(name = "subject", length = 100)
    public Concept getSubject() {
        return subject;
    }
    public void setSubject(Concept subject) {
        this.subject = subject;
    }

    @Id 
    @Column(name = "object", length = 100)
    public Concept getObject() {
        return object;
    }
    public void setObject(Concept object) {
        this.object = object;
    }
    @Id 
    @Column(name = "predicate", length = 100)
    public Concept getPredicate() {
        return predicate;
    }
    public void setPredicate(Concept predicate) {
        this.predicate = predicate;
    }

コンセプト

@NodeEntity(partial = true)
public class ConceptNeoImpl implements java.io.Serializable, Concept {

    private static final long serialVersionUID = 1L;
    private String uri;
    private String label;
    private String ontologyElement;
    private List<Annotation> annotations;
    @RelatedTo(type = "conceptSub", elementClass = TripleDBModel.class)
    private TripleDBModel triple;

    public TripleDBModel getTriple() {
        return triple;
    }

    public void setTriple(TripleDBModel triple) {
        this.triple = triple;
    }

下の画像で使いたい使い方を説明しています

ここに画像の説明を入力してください

次に、テーブルトリプルはneo4jを使用し、コンセプトはjpaとneo4jを使用します。私はEclipseIDEを使用してプログラミングしていますが、エラーを修正するための提案が表示されます。最初のものは次のとおりです。

@RelatedTo(type = "conceptUriSubject", elementClass = Concept.class)

に正しい

@RelatedTo(type = "conceptUriSubject", elementClass = (Class<? extends NodeBacked>) Concept.class)

そして、問題は解決されず、私にネクサスメッセージを与えます

この行の複数のマーカー-注釈属性RelatedTo.elementClassの値はクラスリテラルである必要があります-タイプセーフティ:クラスからクラスへのチェックされていないキャストNodeBacked>-アノテーション属性RelatedTo.elementClassの値はクラスリテラルである必要があります-タイプセーフティ:チェックされていませんクラスからクラスNodeBackedにキャスト>

どんなアイデアも¿¿私はこれに慣れていないので、私はかなり迷子になっていて、すでに春のフォーラムで質問しましたが、成功しませんでした。前もって感謝します

私のプラグインを編集するpom.xml

<plugins>
          <plugin>
            <!-- Execute the main class -->
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <executions>
              <execution>
                <goals>
                  <goal>exec</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <mainClass>org.springframework.data.neo4j.examples.hellograph.App</mainClass>
            </configuration>
          </plugin>
          <plugin>
            <!-- IntelliJ Idea Support -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-idea-plugin</artifactId>
            <version>2.2</version>
            <configuration>
              <downloadSources>true</downloadSources>
              <dependenciesAsLibraries>true</dependenciesAsLibraries>
            </configuration>
          </plugin>



            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <version>1.0</version>
                <dependencies>
                    <!-- NB: You must use Maven 2.0.9 or above or these are ignored (see 
                        MNG-2972) -->
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjrt</artifactId>
                        <version>${aspectj.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjtools</artifactId>
                        <version>${aspectj.version}</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <outxml>true</outxml>
                    <aspectLibraries>
                        <aspectLibrary>
                            <groupId>org.springframework</groupId>
                            <artifactId>spring-aspects</artifactId>
                        </aspectLibrary>
                        <aspectLibrary>
                            <groupId>org.springframework.data</groupId>
                            <artifactId>spring-data-neo4j</artifactId>
                        </aspectLibrary>
                    </aspectLibraries>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>

        </plugins>

Eclipseにインストールされているソフトウェア ここに画像の説明を入力してください

4

2 に答える 2

1

この更新サイトを使用して、EclipseIDEにAspectJプラグインをインストールしてください。

http://download.eclipse.org/tools/ajdt/36/dev/update

次に、コンテキストメニューを使用してプロジェクトのAspectJサポートを有効にできるはずです。

ドメインクラスはNodeBackedインターフェイスを実装するように拡張され、IDEはアノテーションやその他の場所でエラーを発生させません。

混乱させて申し訳ありません。これらの問題は、次のリリースで対処する予定です。

アップデート:

申し訳ありませんが、以前は気づいていませんでしたが、elementClassに配置した概念は実際にはインターフェースであり、@ NodeEntityで注釈が付けられておらず、NodeBackedを拡張していないため、これが実際の問題です。

Springフォーラムでも質問されたと思いますが、そこからの私の提案は次のとおりです。

あなたのコンセプトはインターフェースであり、現在NodeBackedを拡張していません。

一般的に、NodeBackedインターフェースは、@NodeEntityアノテーションを持つクラスに追加されます。

次に、同じ解決策を試すことができます。

  • コンセプトにも@NodeEntityで注釈を付けます。
  • または、ConceptにNodeBackedを拡張させます

重要: elementClassは、具体的な実装を参照する必要があります(これは、ターゲットとの互換性をチェックするために使用されるだけなので、インターフェイスで機能する可能性があります)。

于 2011-05-16T22:39:20.373 に答える
1

Spring Dataは、いくつかのウィービングトリック(aspectJ)を使用してクラスを生成します。https://github.com/SpringSource/spring-data-graph-examples/blob/master/hello-worlds/pom.xmlのように、pomにプラグインを追加する必要があります

于 2011-05-16T14:00:44.630 に答える