MyEclipse Forums
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
carniz
Post subject: Willing to contribute velocity template  PostPosted: Dec 20, 2004 - 12:45 AM
Veteran Member
Veteran Member


Joined: Nov 01, 2004
Posts: 20

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.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
support-rkalla
Post subject:   PostPosted: Dec 20, 2004 - 02:34 PM
Registered Member
Registered Member


Joined: Jan 06, 2004
Posts: 23824

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.

_________________
Riyad
MyEclipse Support
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
support-jeff
Post subject:   PostPosted: Dec 24, 2004 - 12:36 AM
Moderator
Moderator


Joined: Jul 18, 2004
Posts: 357

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.

Quote:

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?

Quote:

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.

Quote:

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

So do we!

Thanx again for the food for thought.

_________________
jeff
MyEclipse Support
 
 View user's profile Send private message  
Reply with quote Back to top
carniz
Post subject: Updated template  PostPosted: Dec 26, 2004 - 12:51 PM
Veteran Member
Veteran Member


Joined: Nov 01, 2004
Posts: 20

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!
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits