  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | JSP - A mailing list about Java Server Pages specification and reference | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | Separating SQL from code | Separating SQL from code 2004-04-07 - By Sean Brydon
Back Hi,
a couple strategies to consider. One is that you can externalize the SQL and put it into an XML file. This is discussed at http://java.sun.com/blueprints/patterns/DAO.html and is implemented in the JavaPetstore. This is mostly done for portsability since sometimes SQL is not that portable.
another strategy is to use CMP, Container Managed Persistence, with EJBs.
hope that helps, Sean
Jean-Christian Imbeault wrote:
>Hi, I'm somewhat new to patterns and J2EE but I was wondering if someone >could help with a question I have. > >I'm wondering if there are any patterns of practices that document ways to >extract SQL from code or that discuss if this is a good thing or not? > >I have read the J2EE Patterns book and done a bit of research (especially on >DAO) but can find anything that talks about a total separation of SQL from >code. I am wondering is removing SQL from code (and possibly placing it in a >properties file or such) might be a good way of putting all the SQL in one >place to make changes (maintenance) easier. > >The best I could find was this article which documents one approach but not >the pros or cons: > >http://www.javapractices.com/Topic105.cjp > >Thanks! > >Jean-Christian Imbeault > >==================================================================== >Companion Site: http://www.corej2eepatterns.com >J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns >List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html >Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected) > >
==================================================================== Companion Site: http://www.corej2eepatterns.com J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)
|
|
 |