Back Forum Reply New

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(Setlt;Bargt; bars) method.  Mine looks like this:

Code:  public void Foo.setBars(Setlt;Bargt; bars) {       Setlt;example.domain.Bargt; localBars = new HashSetlt;example.domain.Bargt;();       Listlt;Longgt; longIds = new ArrayListlt;Longgt;();       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 quot;for (Bar bar : bars) {quot; ... ?

Any help would be greatly appreciated!Thanks,

Peter

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//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(quot;}quot;);
bodyBuilder.indentRemove();
bodyBuilder.appendFormalLine(quot;}quot;);
bodyBuilder.appendFormalLine(quot;for (Employee entity : quot; + entityCollectionName +quot;) {quot;);
bodyBuilder.indent();
bodyBuilder.appendFormalLine(quot;if (!longIds.contains(entity.getId())) {quot;);
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:

bro...a.java?hb=trueCan someone confirm my sanity here?  Surely that is a bug?Thanks,

Peter

FYI -- created a JIRA isue for this:

browse/ROO-1983

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 :-(

@pwagener: Thanks for raising an issue in jira and for providing a fix, but you assigned it as Priority quot;minorquot;, 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 quot;minorquot; problem it is useless at the moment. I wonder, that other people obviously do not have problems with that.

/Klaus

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.

The issue I described above is fixed now (browse/ROO-2078). Please test and let me know here.
Thanks


Originally Posted by klausJyou assigned it as Priority quot;minorquot;, 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?


Originally Posted by andrewsHave 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.


Originally Posted by Alan StewartThe issue I described above is fixed now (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 roogt;
[Thread-9] Missing:
[Thread-9] ----------
[Thread-9] 1) org..roorg..roo.an  notations:jar:1.1.2.BUILD-SNAPSHOT
[Thread-9] obe roogt;
[Thread-9]   Try downloading the file manually from the project website.
[Thread-9] obe roogt;
[Thread-9]   Then, install it using the command:
[Thread-9]       mvn install:install-file -DgroupId=org..roo -DartifactId=org..roo.annotations -Dversion=1.1.2.BUILD-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file
[Thread-9] obe roogt;
[Thread-9]   Alternatively, if you host your own repository you can deploy the file there:
[Thread-9]       mvn deploy:deploy-file -DgroupId=org..roo -DartifactId=org..roo.annotations -Dversion=1.1.2.BUILD-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file -Ducl=[ucl] -DrepositoryId=[id]
[Thread-9] obe roogt;
[Thread-9]   Path to dependency:
[Thread-9]       1) de.klangverfolger.probenplanrobenplan:war:0.1.0.  BUILD-SNAPSHOT
[Thread-9]       2) org..roorg..roo.an  notations:jar:1.1.2.BUILD-SNAPSHOT
[Thread-9] obe roogt;
[Thread-9] ----------
[Thread-9] 1 required artifact is missing.
[Thread-9] obe roogt;
[Thread-9] for artifact:
[Thread-9]   de.klangverfolger.probenplanrobenplan:war:0.1.0.  BUILD-SNAPSHOT
[Thread-9] obe roogt;
[Thread-9] from the specified remote repositories:
[Thread-9]   spring-maven-milestone (milestone),
[Thread-9]   central (maven2),
[Thread-9]   spring-roo-repository (release),
[Thread-9]   DataNucleus_2 (downloads/maven2/),
[Thread-9]   maven-gae-plugin-repo (svn/repository),
[Thread-9]   spring-maven-release (release),
[Thread-9]   JBoss Repo (nexus/content/repositories/releases)
[Thread-9] obe roogt;
¥
Back Forum Reply New