struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject RE: Struts2 + Spring/Hibernate
Date Fri, 13 Nov 2009 13:41:53 GMT
Hi Wild Oscar, thanks for your input.

First, I agree my design needs work with respect to naming conventions and thank you for the
suggestions.  This was more of a very crude example of how I should be relating components
in the Hibernate/Spring/Struts2 design pattern so I can grasp the concept.  In my Struts1.2
days, we didn't leverage spring nor hibernate and wrote our own DAO object framework.  While
it worked nicely, Hibernate has far more benefits.

Now taking the example deeper, lets assume that Person is also related to two other tables
in my database.  For example, one table that stores Payroll and another that stores MenuPermissions.
 I would need to create two additional Entity objects, create their DAO and Service layers
and then in all three entity objects, I would need to annotate the relationship amongst the
3 tables, correct?

When I finally get to the point where this framework will hit the road is when I will have
4 or 5 tables in a database, all with relevant information about a key record or set of records
in the main table and I will need to join all these records together.  In the past we typically
created a single record object for each query we had and while that worked nicely, there were
lots of duplicity that I aim to avoid.

Is this the right path and expectation for hibernate/spring/struts when I have a join between
multiple database tables?


-----Original Message-----
From: wild_oscar []
Sent: Fri 11/13/2009 3:42 AM
Subject: Re: Struts2 + Spring/Hibernate

Seems fine with me.

>   <!-- actions -->
>   <bean id="personAction" scope="prototype"
> class="">
>     <constructor-arg ref="personService"/>
>   </bean>

I don't see any advantage on creating Actions with Spring. It works fine
without it and it seems unnecessary configuration. Perhaps someone else can
point out clear advantages of this.

> Per one example I saw, struts.xml should be as follows:
>   <package name="persons" namespace="/persons" extends="struts-default">
>     <action name="list" class="personAction" method="list">
>       <result name="success">/WEB-INF/pages/persons/list.jsp</result>
>     </action>
>   </package>

I would suggest using wildcards to reduce the configuration of your actions,
and also giving your actions a better name for when you have more than one
domain class (otherwise you don't know if "list" is related to Person or to
Address). For example:

  <package name="persons" namespace="/persons" extends="struts-default">
    <action name="*-*" class="{1}Action" method="{2}">
      <result name="success">/WEB-INF/pages/{1]/{2}.jsp</result>
This example would allow any action named Something-someaction to be mapped
to  method someaction of class SomethingAction and have a result of
View this message in context:
Sent from the Struts - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message