nstanceof doesn't seem to work :-  I couldn't work out how

to create a finder <<Service>> to do this, so I had to resort



to using a plain old hibernate session...



Query query = session.createQuery&#40;"from PublicationImpl"&#41;;

for&#40; Iterator it = query.iterate&#40;&#41;; it.hasNext&#40;&#41;; 
&#41;&#123;

&nbsp; Object o = it.next&#40;&#41;;

&nbsp; if&#40; o instanceof Book &#41;&#123;

&nbsp; &nbsp; System.out.println&#40;"book&#58; " + o.getClass&#40;&#41;&#41;;

&nbsp; &#125;

&nbsp; else if &#40; o instanceof Album &#41;&#123;

&nbsp; &nbsp; System.out.println&#40;"album&#58; " + o.getClass&#40;&#41;&#41;;

&nbsp; &#125;

&nbsp; else if&#40; o instanceof BookImpl &#41;&#123;

&nbsp; &nbsp; System.out.println&#40;"bookImpl&#58; " + 
o.getClass&#40;&#41;&#41;;

&nbsp; &#125;

&nbsp; else if &#40; o instanceof AlbumImpl &#41;&#123;

&nbsp; &nbsp; System.out.println&#40;"albumImpl&#58; " + 
o.getClass&#40;&#41;&#41;;

&nbsp; &#125;

&nbsp; else &#123;

&nbsp; &nbsp; System.out.println&#40;"publication&#58; " + 
o.getClass&#40;&#41;&#41;;

&nbsp; &#125;

&#125;





prints this.



publication&#58; class 
com.netavail.devel.uml.PublicationImpl$$EnhancerByCGLIB$$cff07381

publication&#58; class 
com.netavail.devel.uml.PublicationImpl$$EnhancerByCGLIB$$cff07381

publication&#58; class 
com.netavail.devel.uml.PublicationImpl$$EnhancerByCGLIB$$cff07381

publication&#58; class 
com.netavail.devel.uml.PublicationImpl$$EnhancerByCGLIB$$cff07381

publication&#58; class 
com.netavail.devel.uml.PublicationImpl$$EnhancerByCGLIB$$cff07381

publication&#58; class 
com.netavail.devel.uml.PublicationImpl$$EnhancerByCGLIB$$cff07381

publication&#58; class 
com.netavail.devel.uml.PublicationImpl$$EnhancerByCGLIB$$cff07381

publication&#58; class 
com.netavail.devel.uml.PublicationImpl$$EnhancerByCGLIB$$cff07381





Even if this did work, I still need to store types of Publication for which I 
might

not have a full object -- i.e., I'd need to use them a a Publication rather 
than as

a Book or Album, etc...  I know I can hack andromda to do what I want, but I'd

_much_ rather be able to contribute that work back into andromda for others'

benefit.
_________________________________________________________
Reply to the post : http://galaxy.andromda.org/forum/viewtopic.php?p=2345#2345
Posting to http://forum.andromda.org/ is preferred over posting to the mailing 
list!


-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP, 
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Andromda-user mailing list
Andromda-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/andromda-user

Reply via email to