Announcement Announcement Module
Collapse
No announcement yet.
SDN 2.1.0.RELEASE + Cross-store + Scala + AspectJ - questions and issues Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SDN 2.1.0.RELEASE + Cross-store + Scala + AspectJ - questions and issues

    Hi all,

    I've a number of questions re. the subject, but first let me roughly say what I would like to accomplish.

    In essence I'd love to be able to:
    • write my domain classes using Scala's case classes to take advantage of Scala's pattern matching and such
    • have some of those annotated with @NodeEntity(partial = true)
    • make use of the goodies of SDN's GraphRepository

    Also, I've set up a maven project roughly guided by ideas found here, even though I am not planning to do cross-store with Mongo but with JPA.

    I've looked at the restaurants-social and also at the tests in spring-data-neo4j-cross-store and I've seen that in every case the Java annotated POJOs are all weaved using AspectJ.

    Questions & issues:
    1. is it possible at all not to weave my Scala classes (when doing cross-store I mean...)?
    2. tried weaving (org.codehaus.mojo:aspectj-maven-plugin:1.4 with aspectj 1.7.1) the bytecode produced by scalac (net.alchim31.maven:scala-maven-plugin:3.1.0) using case classes first, got ajc issues. javap shows injected methods but domain class is not implementing NodeBacked... (looks like the "declare parents" issue mentioned in the plugin comment here)
    3. reading Michael's comment, decided to revert to normal Scala classes. Again, same as above, albeit ajc issues change slightly
    4. tried not to weave Scala classes... and, since I get no free beer then (i.e. no .persist() method on my domain classes) and finding also ...cumbersome?... to have a @Transactional method doing both the saves (JPA and Neo4J, albeit it looks like it's the only way to go in both restaurants-social and in the cross-store examples)... I gave a shot at a single call: repository.persist(domainObject), where repository is the Spring-injected class implementing GraphRepository. Interestingly, it appears that it does fire all the JDBC stuff, although it then fails after, since it tries to cast my domain class into a NodeBacked...

    I know it turned out to be a long post and probably also not so immediate to follow but I can provide any further info and, if needed, a sample project to reproduce each (i.e. points 2, 3, 4)

  • #2
    Let me add what I get using LTW:

    Code:
    package com.nexse.domain
    
    import org.springframework.data.neo4j.annotation.{GraphProperty, NodeEntity}
    import javax.persistence._
    import reflect.BeanProperty
    
    @Entity
    @Table(name = "people")
    @NodeEntity(partial = true)
    class Person {
    
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      @Column(name = "id")
      @BeanProperty
      var id: java.lang.Long = _
    
      @Version
      @Column(name = "ver")
      @BeanProperty
      var version: java.lang.Integer = _
    
      @Column(name = "last_name")
      @BeanProperty
      var lastName: String = _
    
      @GraphProperty
      @BeanProperty
      var username: String = _
    
    }
    Code:
    [AppClassLoader@b92d342] error at com/nexse/domain/Person.scala::0 The type com.nexse.domain.Person must implement the inherited abstract method org.springframework.data.neo4j.aspects.core.NodeBacked.getRelationshipTo(Lorg/springframework/data/neo4j/aspects/core/NodeBacked;Ljava/lang/Class;Ljava/lang/String;)
    	see also: org/springframework/data/neo4j/aspects/core/NodeBacked.java::0
    	see also: org/springframework/data/neo4j/aspects/support/node/opt/bamboo-home/xml-data/build-dir/SPRINGDATA-DATAGRAPH-JOB1/spring-data-neo4j-aspects/src/main/java/org/springframework/data/neo4j/aspects/support/node/Neo4jNodeBacking.aj:66::0
    [AppClassLoader@b92d342] error at com/nexse/domain/Person.scala::0 The type com.nexse.domain.Person must implement the inherited abstract method org.springframework.data.neo4j.aspects.core.NodeBacked.projectTo(Ljava/lang/Class;)
    	see also: org/springframework/data/neo4j/aspects/core/NodeBacked.java::0
    	see also: org/springframework/data/neo4j/aspects/support/node/opt/bamboo-home/xml-data/build-dir/SPRINGDATA-DATAGRAPH-JOB1/spring-data-neo4j-aspects/src/main/java/org/springframework/data/neo4j/aspects/support/node/Neo4jNodeBacking.aj:66::0
    [AppClassLoader@b92d342] error at com/nexse/domain/Person.scala::0 The type com.nexse.domain.Person must implement the inherited abstract method org.springframework.data.neo4j.aspects.core.NodeBacked.relateTo(Lorg/springframework/data/neo4j/aspects/core/NodeBacked;Ljava/lang/Class;Ljava/lang/String;)
    	see also: org/springframework/data/neo4j/aspects/core/NodeBacked.java::0
    	see also: org/springframework/data/neo4j/aspects/support/node/opt/bamboo-home/xml-data/build-dir/SPRINGDATA-DATAGRAPH-JOB1/spring-data-neo4j-aspects/src/main/java/org/springframework/data/neo4j/aspects/support/node/Neo4jNodeBacking.aj:66::0
    [AppClassLoader@b92d342] error at com/nexse/domain/Person.scala::0 The type com.nexse.domain.Person must implement the inherited abstract method org.springframework.data.neo4j.aspects.core.NodeBacked.relateTo(Lorg/springframework/data/neo4j/aspects/core/NodeBacked;Ljava/lang/Class;Ljava/lang/String;Z)
    	see also: org/springframework/data/neo4j/aspects/core/NodeBacked.java::0
    	see also: org/springframework/data/neo4j/aspects/support/node/opt/bamboo-home/xml-data/build-dir/SPRINGDATA-DATAGRAPH-JOB1/spring-data-neo4j-aspects/src/main/java/org/springframework/data/neo4j/aspects/support/node/Neo4jNodeBacking.aj:66::0
    [AppClassLoader@b92d342] error at com/nexse/domain/Person.scala::0 The type com.nexse.domain.Person must implement the inherited abstract method org.springframework.data.neo4j.aspects.core.GraphBacked.setPersistentState(Ljava/lang/Object;)
    	see also: org/springframework/data/neo4j/aspects/core/GraphBacked.java::0
    	see also: org/springframework/data/neo4j/aspects/support/node/opt/bamboo-home/xml-data/build-dir/SPRINGDATA-DATAGRAPH-JOB1/spring-data-neo4j-aspects/src/main/java/org/springframework/data/neo4j/aspects/support/node/Neo4jNodeBacking.aj:66::0
    [AppClassLoader@b92d342] error at com/nexse/domain/Person.scala::0 The type com.nexse.domain.Person must implement the inherited abstract method org.springframework.data.neo4j.mapping.ManagedEntity.setPersistentState(Ljava/lang/Object;)
    	see also: org/springframework/data/neo4j/mapping/ManagedEntity.java::0
    	see also: org/springframework/data/neo4j/aspects/support/node/opt/bamboo-home/xml-data/build-dir/SPRINGDATA-DATAGRAPH-JOB1/spring-data-neo4j-aspects/src/main/java/org/springframework/data/neo4j/aspects/support/node/Neo4jNodeBacking.aj:66::0
    Any hints on why both LTW and CTW are not doing what they should using scala classes?

    \j

    Comment


    • #3
      Hi,

      I'm not a SDN expert, but I am the lead of AspectJ - I'll chip in. In principal what you want to do sounds perfectly reasonable. I don't think I have any open issues against AspectJ concerning weaving Scala bytecode (I have worked with the scala guys to fix a few over the years). But having said that I've never tried anything quite as sophisticated as this.

      If you can raise an issue on https://bugs.eclipse.org/bugs/enter_...roduct=AspectJ with a simple test case (very simple if possible, due to the complexity of the weaving that goes on here) - I will take a look when I get some time.

      regards,
      Andy

      Originally posted by julien.sirocchi View Post
      Hi all,

      I've a number of questions re. the subject, but first let me roughly say what I would like to accomplish.

      In essence I'd love to be able to:
      • write my domain classes using Scala's case classes to take advantage of Scala's pattern matching and such
      • have some of those annotated with @NodeEntity(partial = true)
      • make use of the goodies of SDN's GraphRepository

      Also, I've set up a maven project roughly guided by ideas found here, even though I am not planning to do cross-store with Mongo but with JPA.

      I've looked at the restaurants-social and also at the tests in spring-data-neo4j-cross-store and I've seen that in every case the Java annotated POJOs are all weaved using AspectJ.

      Questions & issues:
      1. is it possible at all not to weave my Scala classes (when doing cross-store I mean...)?
      2. tried weaving (org.codehaus.mojo:aspectj-maven-plugin:1.4 with aspectj 1.7.1) the bytecode produced by scalac (net.alchim31.maven:scala-maven-plugin:3.1.0) using case classes first, got ajc issues. javap shows injected methods but domain class is not implementing NodeBacked... (looks like the "declare parents" issue mentioned in the plugin comment here)
      3. reading Michael's comment, decided to revert to normal Scala classes. Again, same as above, albeit ajc issues change slightly
      4. tried not to weave Scala classes... and, since I get no free beer then (i.e. no .persist() method on my domain classes) and finding also ...cumbersome?... to have a @Transactional method doing both the saves (JPA and Neo4J, albeit it looks like it's the only way to go in both restaurants-social and in the cross-store examples)... I gave a shot at a single call: repository.persist(domainObject), where repository is the Spring-injected class implementing GraphRepository. Interestingly, it appears that it does fire all the JDBC stuff, although it then fails after, since it tries to cast my domain class into a NodeBacked...

      I know it turned out to be a long post and probably also not so immediate to follow but I can provide any further info and, if needed, a sample project to reproduce each (i.e. points 2, 3, 4)

      Comment


      • #4
        Hi Andy,

        thanks a lot for your interest, I've just opened an issue on bugzilla (I'm sure you've already received an email about it )

        https://bugs.eclipse.org/bugs/show_bug.cgi?id=392677

        If you need more stuff let me know!
        Kind Regards,
        \j

        Originally posted by Andy Clement View Post
        Hi,

        I'm not a SDN expert, but I am the lead of AspectJ - I'll chip in. In principal what you want to do sounds perfectly reasonable. I don't think I have any open issues against AspectJ concerning weaving Scala bytecode (I have worked with the scala guys to fix a few over the years). But having said that I've never tried anything quite as sophisticated as this.

        If you can raise an issue on https://bugs.eclipse.org/bugs/enter_...roduct=AspectJ with a simple test case (very simple if possible, due to the complexity of the weaving that goes on here) - I will take a look when I get some time.

        regards,
        Andy

        Comment

        Working...
        X