Plug-in for Hibernate-Struts?

Discussions

General J2EE: Plug-in for Hibernate-Struts?

  1. Plug-in for Hibernate-Struts? (3 messages)

    I want to use Hibernate 2.1 with Struts 1.2.2 on JBoss 3.2.5. I have been searching the net for a way to get Hibernate connected to the others. Someone told me that one has to write a plug-in.
    Can anyone help me with the code?

    Threaded Messages (3)

  2. its NOT needed[ Go to top ]

    no you do not need a plugin to use hibernate with any of those other technologies. generally, an application will create one instance of a SessionFactory for the entire application. one common approach is to place this object in application/servlet context and then access it from Struts Actions (see note below).

    the hibernate website links to a plugin that can be incorporated into a struts project: http://www.hibernate.org/105.html

    the plugin is a class that gets loaded by the main action servlet. it creates an instance of the SessionFactory, builds and configures it, then places it in ServletContext under the key "net.sf.hibernate.SessionFactory".

    Your Struts actions would then access the session factory with a line such as the following:

    SessionFactory sessions = (SessionFactory)servlet.getServletContext().getAttribute("net.sf.hibernate.SessionFactory");

    in order to use the supplied plugin u will need to add a <plugin>...</plugin> entry to your struts-config.xml file.

    While this may be an appropriate solution for relatively small web applications, proper application design does not advocate such an implementation. Rod Johnson's approach, an application context framework with bean factory (as described in J2EE Design & Development) is much more advantageous for component seperation and independence. I would suggest looking at his book.
  3. Re:Plug-in for Hibernate-Struts?[ Go to top ]

    I want to use Hibernate 2.1 with Struts 1.2.2 on JBoss 3.2.5. I have been searching the net for a way to get Hibernate connected to the others. Someone told me that one has to write a plug-in.Can anyone help me with the code?
    See this link
    http://sourceforge.net/project/showfiles.php?group_id=49385&package_id=76625

    Also see this article
    Object-relation mapping without the container

    --
    Andrew
    Java201.com
  4. Re:Plug-in for Hibernate-Struts?[ Go to top ]

    Thanks for all the help. I managed to get it working without any plug-in.