-
1. Re: Problems getting the type of a node
cpob Nov 16, 2006 9:14 AM (in response to lelaub)Yeah, I've been burned by this recently too.
However, if you do a .toString() on the object, it displays the proper class name with the name of the node in parens: 'EndState(End)'
My ghetto fix around this was to .toString() and then parse the text until the first parenthesis.
The to string just does a getClass().getName(), but if I do that straight off the object, it returns Node, but .toString() displays the right value. -
2. Re: Problems getting the type of a node
olivier_debels Nov 16, 2006 9:19 AM (in response to lelaub)Isn't the reason for this that you get a hibernate proxy for the node instead of the real Node. The class hierarchy is not known by this proxy. you can retrieve the real object and try typing there...
public static Object getProxiedObject(Object proxy) { if (proxy instanceof HibernateProxy) { LazyInitializer initializer = ((HibernateProxy) proxy) .getHibernateLazyInitializer(); return initializer.getImplementation(); } return proxy; }
-
3. Re: Problems getting the type of a node
cpob Nov 16, 2006 9:47 AM (in response to lelaub)Thanks, I'll give that a shot. I figured it was something like that, but I didn't have the time to figure out a real solution (eep). Though my fix is a hack, it works! ;)
-
4. Re: Problems getting the type of a node
lelaub Nov 16, 2006 10:52 AM (in response to lelaub)Thanks Olivier, that really helped me and solved my problem.
I wasn't aware of that, seems that I have to go over the books again :)
cpob: Thanks for your reply, actually i prefer instanceof instead of substring ;) - but thank you anyway. -
5. Re: Problems getting the type of a node
cpob Nov 16, 2006 11:16 AM (in response to lelaub)Olivier, I used your method, and it works like a charm, thanks.
I'm now using the instanceof like a proper developer should ;)