Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Non-existent 'Employee' Type in JavaBean

  1. #1
    Join Date
    Jan 2011
    Posts
    13

    Default Non-existent 'Employee' Type in JavaBean

    I just picked up Roo 1.1.1, and decided to crank up a new project to play around with it. However, I've run into a weird problem that I'm not entirely sure is the fault of my own ignorance! Any help would be greatly appreciated.

    Here is a Roo script that I've used to reproduce the problem (attached as 'roo.script.txt'):

    Code:
    // Spring Roo 1.1.1.RELEASE [rev 156ccd6] log opened at 2011-01-12 09:52:47
    download status
    download accept terms of use
    project --topLevelPackage example
    persistence setup --provider DATANUCLEUS --database GOOGLE_APP_ENGINE 
    entity --class ~.domain.Bar
    entity --class ~.domain.Foo 
    field set --fieldName bars --type ~.domain.Bar
    exit
    // Spring Roo 1.1.1.RELEASE [rev 156ccd6] log closed at 2011-01-12 09:57:44
    Nothing too exciting here: create a Google AppEngine project with two entities, and create a one-to-many from the 'Foo' type to the 'Bar' type. The script runs without an error and exits cleanly.

    However, look at the generated Foo_Roo_JavaBean.aj file; specifically the setBars(Set<Bar> bars) method. Mine looks like this:

    Code:
       public void Foo.setBars(Set<Bar> bars) {
            Set<example.domain.Bar> localBars = new HashSet<example.domain.Bar>();
            List<Long> longIds = new ArrayList<Long>();
            for (Key key : barsKeys) {
                if (!longIds.contains(key.getId())) {
                    longIds.add(key.getId());
                }
            }
            for (Employee entity : bars) {
                if (!longIds.contains(entity.getId())) {
                    longIds.add(entity.getId());
                    barsKeys.add(KeyFactory.createKey(Bar.class.getName(), entity.getId()));
                }
                localBars.add(entity);
            }
            this.bars = localBars;
        }
    What is that second 'for' loop doing? Where did the Employee type come from? Shouldn't that be "for (Bar bar : bars) {" ... ?

    Any help would be greatly appreciated!


    Thanks,

    Peter
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2011
    Posts
    13

    Default Found it in the source code....

    I decided to dig into this issue a little bit more by grabbing the Roo source and seeing if it that would shed any light on the 'Employee' type being generated in an AspectJ file under certain circumstances.

    Volia. Have a look at ...

    /addon-javabean/src/main/java/or/springframework/roo/addon/javabean/JavaBeanMetadata.java


    ... within the ...

    private InvocableMemberBodyBuilder getEntityCollectionMutatorBody(FieldMetadata field, JavaSymbolName entityIdsFieldName)

    ... method. In the source from HEAD that I cloned today, look around line 364, when the method is building the body of the AspectJ file:

    Code:
    bodyBuilder.appendFormalLine("}");
    bodyBuilder.indentRemove();
    bodyBuilder.appendFormalLine("}");
    bodyBuilder.appendFormalLine("for (Employee entity : " + entityCollectionName +") {");
    bodyBuilder.indent();
    bodyBuilder.appendFormalLine("if (!longIds.contains(entity.getId())) {");
    bodyBuilder.indent();
    (emphasis mine) I'm guessing this made it past unit tests because the test uses the Employee type itself. You can see it in the FishEye source browser as well here:

    https://fisheye.springsource.org/bro...a.java?hb=true


    Can someone confirm my sanity here? Surely that is a bug?


    Thanks,

    Peter

  3. #3
    Join Date
    Jan 2011
    Posts
    13

    Default

    FYI -- created a JIRA isue for this:

    https://jira.springframework.org/browse/ROO-1983

  4. #4
    Join Date
    Jan 2011
    Posts
    1

    Default "Employee entity"

    this is clearly a bug also a funny one but it is a problem. Did found any work around for it? otherwise it renders the release generally unusable :-(

  5. #5
    Join Date
    Jan 2011
    Posts
    10

    Default Minor problem

    @pwagener: Thanks for raising an issue in jira and for providing a fix, but you assigned it as Priority "minor", which means there is an easy work around. Does compiling the source myself is an easy workaround? Or do I miss something?
    For me Roo is really a quantum leap, but with this "minor" problem it is useless at the moment. I wonder, that other people obviously do not have problems with that.

    /Klaus

  6. #6
    Join Date
    Dec 2005
    Posts
    929

    Default

    Sorry everyone - I fixed this specific issue in ROO-1983. However, there is another regression-type bug in the same code in that collection elements that are @RooEntity's are not being considered for inclusion as GAE-interested fields. The script will not generate the same code as listed above. This will be fixed soon.
    Alan Stewart
    Spring Roo Committer
    twitter @alankstewart

  7. #7
    Join Date
    Dec 2005
    Posts
    929

    Default

    The issue I described above is fixed now (https://jira.springsource.org/browse/ROO-2078). Please test and let me know here.
    Thanks
    Alan Stewart
    Spring Roo Committer
    twitter @alankstewart

  8. #8
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    667

    Lightbulb

    Quote Originally Posted by klausJ View Post
    you assigned it as Priority "minor", which means there is an easy work around. Does compiling the source myself is an easy workaround? Or do I miss something?
    Have you tried the workaround of creating an Employee class in the same package as the affected entity?
    Andrew Swan
    "Now is the EJB of our discontent made glorious Spring"

  9. #9
    Join Date
    Jan 2011
    Posts
    10

    Default

    Quote Originally Posted by andrews View Post
    Have you tried the workaround of creating an Employee class in the same package as the affected entity?
    Not yet, but I seriously thought about that.

  10. #10
    Join Date
    Jan 2011
    Posts
    10

    Default Tried build snapshot with no success.

    Quote Originally Posted by Alan Stewart View Post
    The issue I described above is fixed now (https://jira.springsource.org/browse/ROO-2078). Please test and let me know here.
    Thanks
    I tried with ROO/spring-roo-1.1.2.BUILD-SNAPSHOT_20110207.052044-2c2604a.zip
    After doing a lot of work, it stopped with the following error (I didn't try to download anything manually so far). Looks more like a general build error, not related to our issue.

    [INFO] ------------------------------------------------------------------------
    [Thread-9] [ERROR] BUILD ERROR
    [Thread-9] [INFO] ------------------------------------------------------------------------
    [Thread-9] [INFO] Failed to resolve artifact.
    [Thread-9] obe roo>
    [Thread-9] Missing:
    [Thread-9] ----------
    [Thread-9] 1) org.springframework.roo:org.springframework.roo.an notations:jar:1.1.2.BUILD-SNAPSHOT
    [Thread-9] obe roo>
    [Thread-9] Try downloading the file manually from the project website.
    [Thread-9] obe roo>
    [Thread-9] Then, install it using the command:
    [Thread-9] mvn install:install-file -DgroupId=org.springframework.roo -DartifactId=org.springframework.roo.annotations -Dversion=1.1.2.BUILD-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file
    [Thread-9] obe roo>
    [Thread-9] Alternatively, if you host your own repository you can deploy the file there:
    [Thread-9] mvn deploy:deploy-file -DgroupId=org.springframework.roo -DartifactId=org.springframework.roo.annotations -Dversion=1.1.2.BUILD-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
    [Thread-9] obe roo>
    [Thread-9] Path to dependency:
    [Thread-9] 1) de.klangverfolger.probenplanrobenplan:war:0.1.0.BUILD-SNAPSHOT
    [Thread-9] 2) org.springframework.roo:org.springframework.roo.an notations:jar:1.1.2.BUILD-SNAPSHOT
    [Thread-9] obe roo>
    [Thread-9] ----------
    [Thread-9] 1 required artifact is missing.
    [Thread-9] obe roo>
    [Thread-9] for artifact:
    [Thread-9] de.klangverfolger.probenplanrobenplan:war:0.1.0.BUILD-SNAPSHOT
    [Thread-9] obe roo>
    [Thread-9] from the specified remote repositories:
    [Thread-9] spring-maven-milestone (http://maven.springframework.org/milestone),
    [Thread-9] central (http://repo1.maven.org/maven2),
    [Thread-9] spring-roo-repository (http://spring-roo-repository.springsource.org/release),
    [Thread-9] DataNucleus_2 (http://www.datanucleus.org/downloads/maven2/),
    [Thread-9] maven-gae-plugin-repo (http://maven-gae-plugin.googlecode.com/svn/repository),
    [Thread-9] spring-maven-release (http://maven.springframework.org/release),
    [Thread-9] JBoss Repo (https://repository.jboss.org/nexus/content/repositories/releases)
    [Thread-9] obe roo>

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •