From: <jma...@rh...> - 2008-11-22 15:19:34
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><style type="text/css"><!-- #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } --></style> <title>[rhq-project.org rhq] [2086] enhance hibernate.jsp to support DML-style operations; </title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>2086</dd> <dt>Author</dt> <dd>jmarques</dd> <dt>Date</dt> <dd>2008-11-22 09:19:29 -0600 (Sat, 22 Nov 2008)</dd> </dl> <h3>Log Message</h3> <pre>enhance hibernate.jsp to support DML-style operations; </pre> <h3>Modified Paths</h3> <ul> <li><a href="#rhqtrunkmodulesenterpriseguiportalwarsrcmainwebappadminhibernatejsp">rhq/trunk/modules/enterprise/gui/portal-war/src/main/webapp/admin/hibernate.jsp</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="rhqtrunkmodulesenterpriseguiportalwarsrcmainwebappadminhibernatejsp"></a> <div class="modfile"><h4>Modified: rhq/trunk/modules/enterprise/gui/portal-war/src/main/webapp/admin/hibernate.jsp (2085 => 2086)</h4> <pre class="diff"> <span class="info">--- rhq/trunk/modules/enterprise/gui/portal-war/src/main/webapp/admin/hibernate.jsp 2008-11-22 13:10:48 UTC (rev 2085) +++ rhq/trunk/modules/enterprise/gui/portal-war/src/main/webapp/admin/hibernate.jsp 2008-11-22 15:19:29 UTC (rev 2086) </span><span class="lines">@@ -22,6 +22,7 @@ </span><span class="cx"> <%-- Author: Greg Hinkle </span><span class="add">+ Author: Joseph Marques </span><span class="cx"> Copyright: 2008 Red Hat --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> </span><span class="lines">@@ -49,6 +50,8 @@ </span><span class="cx"> String hql = request.getParameter("hql"); String namedQuery = request.getParameter("namedQuery"); List results = null; </span><span class="add">+ boolean isDMLStyle = true; + int resultSize = 0; </span><span class="cx"> long executionTime = 0; String error = null; QueryTranslator qt = null; </span><span class="lines">@@ -120,7 +123,11 @@ </span><span class="cx"> qt.compile(null, false); sql = qt.getSQLString(); </span><span class="rem">- out.write("<b>SQL: </b><textarea rows=\"10\" cols=\"120\">" + sql + "</textarea>"); </span><span class="add">+ if (sql == null) { + out.write("Could not get SQL translation for DML-style operation"); + } else { + out.write("<b>SQL: </b><textarea rows=\"10\" cols=\"120\">" + sql + "</textarea>"); + } </span><span class="cx"> ParameterTranslations pt = qt.getParameterTranslations(); if (pt != null) { </span><span class="lines">@@ -150,8 +157,10 @@ </span><span class="cx"> </table> </c:if> <% </span><span class="add">+ if (hql.replaceAll("\\s*", "").trim().toLowerCase().startsWith("select")) { + isDMLStyle = false; + } </span><span class="cx"> </span><span class="rem">- </span><span class="cx"> if (request.getParameter("execute") != null) { long start = System.currentTimeMillis(); </span><span class="lines">@@ -171,8 +180,15 @@ </span><span class="cx"> //out.println("parameter " + pn + " = " + paramterValue); q.setParameter(pn, paramterValue); } </span><span class="rem">- q.setMaxResults(MAX_ROWS); - results = q.list(); </span><span class="add">+ + if (isDMLStyle) { + resultSize = q.executeUpdate(); + results = new ArrayList(); + } else { + q.setMaxResults(MAX_ROWS); + results = q.list(); + resultSize = results.size(); + } </span><span class="cx"> request.setAttribute("results", results); </span><span class="lines">@@ -192,14 +208,14 @@ </span><span class="cx"> <br/> <c:if test="${param['execute'] != null and results != null}"> </span><span class="rem">- <b>Executed in <%=executionTime%>ms. Found <%=results.size()%> rows. <%=executedSQL.size()%> round trips.</b> </span><span class="add">+ <b>Executed in <%=executionTime%>ms. Found or updated <%=resultSize%> rows. <%=executedSQL.size()%> round trips.</b> </span><span class="cx"> </c:if> <c:if test="${error != null}"> <pre>${error}</pre> </c:if> </span><span class="rem">-<c:if test="${results != null}"> </span><span class="add">+<c:if test="${(isDMLStyle == false) and (results != null)}"> </span><span class="cx"> <hr> <table border="1"> </span> </pre> </div> </div> </body> </html> |