the exception is happening in the de-marshal stage of jo4neo and
appears to be either a bug, or a situation where some kind of error or
warning would be helpful.
jo4neo does not help with traversers, but does help in taking the
results of a traverser and converting to java objects.
in your case it looks like jo4neo thinks it found a plural-primitive
field. That means a Collection of some primitive type,
Collection<String> for example...but that's not the case, so when it
attempts to gain the templated type, it's getting a class cast
exception. I think just a look at your bean class would help us
figure out what's going wrong. can you attach or past that class in a
message?
Taylor
Collection<?>
Sent from my HTC
-----Original Message-----
From: Stefan Berndt <gevest...@googlemail.com>
Sent: 28 June 2010 3:35 AM
To: jo4neo <jo4...@googlegroups.com>
Subject: Re: Problem with Traversing
The example with the TraverserProvider i understand.
the problem is f.ex.:
// @neo(traverser= ModuleTraverser.class)
// private Collection elements;
//
// public Collection getElements() {
// return elements;
// }
doesn't work and i get an Exception when i call getElements.
i need traversing through such a graph:
http://picasaweb.google.com/112639720921939285519/UntitledAlbum#5487738459476662642
Bets Regards,
Stefan
> http://www.neo4j.org - Your high performance graph database.http://www.thoughtmade.com- Scandinavia's coolest Bring-a-Thing party.
>
> On Fri, Jun 25, 2010 at 10:59 AM, Stefan Berndt <gevestber...@googlemail.com
>
> > wrote:
> > Hello Peter,
>
> > I think I understand something wrong here
[The entire original message is not included]
I suspect that in your original example, if you were to type your
Collection like this:
Collection<Object> getElements(...)
In your example, it's just
Collection getElements()
On my end I need to add logic to detect missing generics and warn the
user so that the problem isn't obtuse and confusing...as well as
document this clearly. Please type this Collection<....> and give it
another try.
The idea behind traverser support in jo4neo is that sometimes, you
want to bring in part of the graph into your object as a collection of
child items. NEO4J traversers just walk the graph, perhaps you want
to filter out unmatching types...like in my user/roles example, you
only want roles, ignore the users...your traverser collection would
be:
Collection<Role> getRoles()...
Then jo4neo will take the traverser you provided, and ignore any nodes
that cannot be coerced as type "Role". The exception happens because
your method gives no generic type. Ideally you'd want to type it as
something a little more specific as opposed to "Object", maybe Element
or BaseElement, whatever makes the most sense in your domain.
Taylor
Please see http://code.google.com/p/jo4neo/source/browse/#svn/trunk/jo4neo/src/test/java/test/traverser
I used your code to create a simple test case. Notice my traverser is
restricted to Object. If you'd like to filter that set, give it
another type. I had to make a few changes:
1. Collections without a generic type specifier cause jo4neo to bomb.
You'd think the default would be of type Object, but that's not the
case with Java, if no generic type is given, the introspection finds
none. So the test case just starts with Collection<Object>. You can
restrict that as needed.
2. I moved the annonymous inner type out. The Traverser providers
need to be beans in the strict sense. Jo4neo needs to instantiate
them using a visible default constructor.
Hope that helps. Thanks for providing the code for us, it made it
easier for me to construct this example. Hope to hear back on how it
goes.
Taylor
On Mon, Jun 28, 2010 at 8:58 AM, Stefan Berndt
<gevest...@googlemail.com> wrote: