• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Persistence layer on Struts app

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm currently working on a website where I've been using Struts. To keep things clean, I layered the application, having my own jdbc database access classes to map the objects from the bussiness layer, but it has been a complete failure in terms of performance, so I'm thinking on using something like Hibernate, JDO, Castor, etc.

I need it to work in a short span of time, and maintaining the database queries and structure (which are a bit complicated and inherited from a fully functional app) unchanged.

Which is the persistante layer to go for?

Thanks in advance

(Sorry for my English, it's a bit rusty)

[ October 19, 2007: Message edited by: raul marzo ]
[ October 19, 2007: Message edited by: raul marzo ]
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is not really a Struts question. Generally you can get better performance with optimized queries and JDBC than you can get with an object mapping tool in the middle. Do you know where the performance issues are coming from? Also if you are stuck with an existing database structure and logic that is implemented in the data layer (queries, views, stored procedures, etc) then trying to fit them to an object mapping tool can be very challenging.

- Brent
 
raul marzo
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the major problem comes with the inability to mantain database connections during a user session, because I couldn't figure out how to make a connection accesible to the beans that I use in the bussiness layer, or at least, not in a direct way without passing them throught actions, trying to maintain the different layers as independent as possible.

Any suggestions about how to fix that?
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One (drastic, but generally useful) way to handle getting database connections beans in your beans without passing them through actions is to inject the connection into the beans. You can do this using the Spring framework (or other dependency injection containers). This is extremely useful - when you allow spring to manage the instantiation of your classes, you can remove some of the complexity from passing objects around to having them injection. IMHO, it makes for much cleaner code, and simplifies your life to some extent.
Hope this helps.
 
raul marzo
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you talk about using the Spring Framework, are you saying to use Spring together with Struts, or simply replace Struts for Spring? I ask this because I need to work rather soon, and I don't have the time to recode all my application again.
 
John Melton
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, you would use struts in conjunction with spring. A good place to look for getting started with this might be: http://www-128.ibm.com/developerworks/java/library/j-sr2.html
Hope this helps.
 
raul marzo
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your replies.

One last question. If I decide to stick with my old jdbc access to database, and I implement it using the singleton pattern, would that be any good?

I mean, the problem was that I was creating a connection for every query to the database, but I think that if I only have one instance of the classes that access the database, that would be enough to maintain that connections alive, doesn't it?
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What business layer technology are you using? There should be a database connection pooling strategy or technology that would fit your application.

- Brent
 
raul marzo
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all.

At last, the application is up and running, and working quite well. I finnaly used a self made ConnectionPool class, combined with a singleton approach.

 
reply
    Bookmark Topic Watch Topic
  • New Topic