facebook

Willing to contribute velocity template

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #221544 Reply

    carniz
    Member

    Hi,

    I have written a velocity template that I would like to contribute to MyEclipse. It generates a “SLHSB” (Stateless Hibernate Session Bean) per entity type / database table, eg for “customer” entities (in the customer table) there will be a CustomerServiceBean that provides all CRUD operations (saveOrUpdate, delete, findById, findByExample, findAll) required for most applications.

    Using these methods, you can design your master/detail views without having to write one single line of EJB code – just use CustomerService.findAll() in the /customerList.do action, CustomerService.findById() in the /customerDetail.do action, CustomerService.findByExample() in the /customerSearch.do action, and CustomerService.saveOrUpdate() or CustomerService.delete() in the /customerDetail.do?action=edit action.

    An example of a SLHSB can be seen here:
    http://www.studenter.hb.se/~arch/KontaktServiceBean.java.html

    In fact, if this template could be called from eg the MyEclipse database explorer, the required steps to build a complete J2EE multi layered application could be reduced to

    1. Design the database [manual]
    2. Generate the middle layer (business objects /w Hibernate mappings + session beans) [automatic]
    3. Design the user interface [manual]

    This equals only two manual steps, and could really reduce the time from idea to finished application.

    Now, this template will not be called by MyEclipse just by adding it in the plugins\com.genuitec.eclipse.hibernate_3.8.3\templates directory as I assume that the various templates are called explicitly by MyEclipse. I have tried to rename my template to say, mappedobject.vm to “trick” MyEclipse into using it, but as it does not generate the same file as the original template the generation fails.

    Also, the user should be able to define the JNDI url of the SessionFactory used by the generated beans (see example for usage) so I kindly suggest that you (if you decide to implement this template) add a wizard where the user can define the value of this URL (suggestably: java:/[project name]/SessionFactory or java:/[database schema]/SessionFactory).

    Related:
    – For JBoss, you could add a Hibernate SAR/MBean module wizard that generates the SessionFactory configuration (see thread http://www.myeclipseide.com/PNphpBB2+file-viewtopic-t-4653.html)
    as the first step, and the business objects + hibernate mappings as a second step. Ideally, this session factory config should be managed by MyEclipse so that the user could browse for and choose session factory when running the SLHSB wizard.

    Summary:
    If you like this idea, I suggest that you add a “Stateless Hibernate Session Bean” wizard that could be launched either/or from File->New..->J2EE->EJB and the popup menu of a table(connection?) in the database explorer perspective.

    Did I forget anything…umm…oh, yeah the template itself can be found here:
    http://www.studenter.hb.se/~arch/slhsb.vm

    Will MyEclipse be known for “the fastest J2EE development method ever”? I hope so. Regardless if, the development time of a many J2EE projects could be greatly reduced anyhow.

    Hope you like the idea.

    Regards,
    Mikael.

    #221571 Reply

    Riyad Kalla
    Member

    Mikael,
    I’ve sent your (generous) offer off to the devs to have a look at. If someone doesn’t get back to ASAP its only because we are trying to wrap up a lot of things before the Christmas break here in the US and things are a bit hectic.

    #221809 Reply

    support-jeff
    Member

    Mikael –

    Great ideas. We are already going down this road – generation of DAO and even bare-bones Struts CRUD actions and JSP are in the plan. However, most development efforts will go into improving the usability of the mapping tools in upcoming releases.

    I have tried to rename my template to say, mappedobject.vm to “trick” MyEclipse into using it, but as it does not generate the same file as the original template the generation fails.

    Probably because you reference context variables that do not exist. At some point I think we plan to make the variable public, but by looking at the current templates you can probably get a good feel for what they are 😉 Or are you just saying that the filename comes out incorrect?

    Also, the user should be able to define the JNDI url of the SessionFactory used by the generated beans

    This is aleady supported in the HibernateSessionFactory you can have generated for your project when you add Hibernate capabilities.

    Will MyEclipse be known for “the fastest J2EE development method ever”? I hope so.

    So do we!

    Thanx again for the food for thought.

    #221850 Reply

    carniz
    Member

    Hi,

    just wanted to inform you that I have now updated/fixed the velocity template – it was a stupid copy/paste error that prevented the template from working correctly.

    To try it out, rename mappedobject.vm in $MYECLIPSE_HOME\eclipse\plugins\com.genuitec.eclipse.hibernate_3.8.3\templates
    to ORIGINAL_mappedobject.vm (or similar) and then copy the file
    http://www.studenter.hb.se/~arch/slhsb.vm
    to the same directory and rename it to mappedobject.vm

    Note that the generated file will be named AbstractSomething.java instead of SomethingServiceBean.java, as MyEclipse doesn’t know the original template has been replaced. To use the EJB you will therefore have to rename the generated file manually.

    Merry Christmas!

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: Willing to contribute velocity template

You must be logged in to post in the forum log in