- This topic has 4 replies, 3 voices, and was last updated 18 years, 9 months ago by bdlink.
-
AuthorPosts
-
bdlinkMemberTrying to use XDoclet with MyEclipse, and so far it is a bit frustrating trying to find documentation. I am trying to add finder methods, and the generated ejb-jar.xml file says “<!– Write a file named ejb-finders-StudentBean.xml if you want to define extra finders. –>”. I assume extra means on top of findByPrimaryKey.
So I defined a directory merge, at the top level in the project, set the properties for MyEclipse-XDoclet>StandardEJB>ejbdoclet>mergeDir to merge. I added a ejb-finders-StudentBean.xml file with the following contents:
<query> <query-method> <method-name>findByName</method-name> <method-params> <method-param>java.lang.String</method-param> <method-param>java.lang.String</method-param> </method-params> </query-method> <ejb-ql> SELECT OBJECT(s) FROM Student AS s WHERE s.lastName = ?1 AND s.firstName = ?2 </ejb-ql> </query> <query> <query-method> <method-name>findByStudentNumber</method-name> <method-params> <method-param>java.lang.String</method-param> </method-params> </query-method> <ejb-ql> SELECT OBJECT(s) FROM Student AS s WHERE s.studentNumber = ?1 </ejb-ql> </query> <query> <query-method> <method-name>findAll</method-name> <method-params/> </query-method> <ejb-ql> SELECT OBJECT(s) FROM Student AS s </ejb-ql> </query>
ran myeclipse>xdoclet and looked at the ejb-jar.xml file – no change from before, the query tags were ignored.
I have found lots of trivial CMP examples with no finder or select methods. relationship methods are somewhat intuitive as there are abstract methods in the bean class to add attributes for the generated stuff. Should I be adding something somewhere so the finder methods make it into the home interfaces?
Any help would be appreciated in terms of what I may be doing wrong, and where this is documented, so I can move on to the next steps.
Thanks
Riyad KallaMemberTrying to use XDoclet with MyEclipse, and so far it is a bit frustrating trying to find documentation.
Just a tip, the XDoclet support in ME is just that, support for run-of-the-mill XDoclet. If you are googling for documentation, just looking normal XDoclet tutorials, they will all work fine in MyEclipse.
So I defined a directory merge, at the top level in the project, set the properties for MyEclipse-XDoclet>StandardEJB>ejbdoclet>mergeDir to merge. I added a ejb-finders-StudentBean.xml file with the following contents:
Silly question, but your top level directory IS called merge correct? Did you try /merge as well?
bdlinkMemberYes, thank you, I started with the XDoclet site and found their documentation difficult to follow as well (I have previously done the descriptors by hand, and used ant to build, though I have also used JBOSS IDE and the old 1.3 sun reference deploytool – first time I am trying XDoclet). XDoclet seems to be assuming you are using ant directly to run your project, not MyEclipse. I have gone through the myeclipse tutorials, and have looked at the laliluna tutorials.
Yes, the merge directory is called merge. I tried /merge in the myeclipse-Xdoclet mergeDir params which did not result in the file being added to the ejb-jar.xml (no change), but thanks for the suggestion.
I am using J2EE 1.4 and EJB 2.1 spec if that makes a difference, the MyEclipse tutorials say that you need to use J2EE 1.3 with XDoclet, but the XDoclet people say it is fine with J2EE 1.4.
GregMemberTry setting the merge directory attribute on the ejbcmp subtask under ejbdoclet. See if that makes a difference. Note: I have not actually performed a successful merge by doing this, I’m just making a suggestion.
bdlinkMemberOK,
I found the answer, I think. The comment in the ejb-jar.xml is misleading. What you have to do is use @ejb.finder at the bean class which then adds in the info. Probably XDoclet knows it does not make sense to merge the file so it silently ignores it?In any case, I have figured out how to get it to add finder methods, so I am happy again.
-
AuthorPosts