That indeed is evil, JP. Could you raise an issue on this please? Please copy even your explanation in there. Fully agree.
Cheers, /peter neubauer TC CEO of the year - vote for Emil Eifrém! http://crunchies2011.techcrunch.com/nominate/ Google:neubauer.peter Skype:peter.neubauer Phone: +46 704 106975 LinkedIn http://www.linkedin.com/in/neubauer Twitter @peterneubauer brew install neo4j && neo4j start heroku addons:add neo4j On Fri, Dec 9, 2011 at 4:02 PM, Jean-Pierre Bergamin <jpberga...@gmail.com> wrote: > Dear neo4j community and developers > > For the second time we stumbled about Iterables that are no Iterables > in Neo4j. IndexHits e.g. extends Iterator and Iterable and states in > its documentation that is not really an iterable but always returns > "this" in calls to iterator(). So far so good. > > Now when using Spring Data Neo4j, the IndexHits is wrapped and hidden > behind ClosableIterable and IterableAdapter etc. The user has no idea > anymore that those IterableWrapper and ClosableIterable things he gets > back are no iterables at all - well the names tell him of course that > those things *are* Iterables. This leads to very, very strange > behaviour like this: > > @Test > public void ouch() { > Device d1 = new Device("d1").persist(); > Device d2 = new Device("d2").persist(); > > ClosableIterable<Device> devices = deviceRepository().findAll(); > assertThat(devices, hasItems(d1)); > assertEquals(1, IteratorUtil.count(devices)); > } > > We add two devices to our DB, but the test clearly states that > findAll() only returns one (assertEquals(1, > IteratorUtil.count(devices))). > As an exercise for the reader: explain why this test misleads you.... > > Iterable should always return a valid iterator for every call to > iterator(). Implementing Iterable just to be able to use an iterator > in a for loop is evil..... >:-) > > > Best regards, > James > _______________________________________________ > NOTICE: THIS MAILING LIST IS BEING SWITCHED TO GOOGLE GROUPS, please register > and consider posting at https://groups.google.com/forum/#!forum/neo4j > > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user _______________________________________________ NOTICE: THIS MAILING LIST IS BEING SWITCHED TO GOOGLE GROUPS, please register and consider posting at https://groups.google.com/forum/#!forum/neo4j Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user