Results 1 to 5 of 5
Thread: Hibernate queries in jsp page
- 05-27-2010, 08:13 AM #1
Member
- Join Date
- May 2010
- Posts
- 2
- Rep Power
- 0
Hibernate queries in jsp page
I have a jsp page something like this,
I need to convert this query using hibernate.which taglib can i use to write hql query.Java Code:<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %> <sql:query var="TypeMaster" scope="request"> SELECT c_org_id,c_org_name FROM t_gb_organization_master order by c_org_name; </sql:query>
Can anybody help me?
- 05-27-2010, 08:19 AM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
You should consider those sql tags as taboo and only ever use them for quick tests.
They should never find their way to production. Even the sun tutorial says they are "designed for quick prototyping and simple applications. For production applications, database operations are normally encapsulated in JavaBeans components".
- 05-27-2010, 09:08 AM #3
Member
- Join Date
- May 2010
- Posts
- 2
- Rep Power
- 0
Hibernate queries in jsp
Actually, I have a webapplication which is using struts1.x with mysql connection .I am trying to change the web application using hibernate with struts1.x.
In my action class i can write hibernate query like this
In my previous webapplication i have some SQLqueries(Java Code:ServletContext context = request.getSession().getServletContext(); /*Retrieve Session Factory */ SessionFactory _factory = (SessionFactory) context.getAttribute(HibernatePlugIn.SESSION_FACTORY_KEY); /*Open Hibernate Session */ Session session = _factory.openSession(); String HQL_QUERY = "select NNoOfAttempt,CStatus,CLastAccessedTime,CBranchId," + "CGroupId, COrgId,CStateId,CRegionId,CUserName from TGbUserMaster" + " where CUserName='" + userId + "' and CPassword='" + encryptPass + "'"; Query query = session.createQuery(HQL_QUERY);) written in jsp page, Now i need some way to convert this sql queries in jsp page to hql queriesJava Code:<sql:query var="TypeMaster" scope="request"> SELECT c_org_id,c_org_name FROM t_gb_organization_master order by c_org_name; </sql:query>
But am really not understanding how to write queries in jsp.Can you please help me?
- 05-27-2010, 09:25 AM #4
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
You simply don't write queries in JSPs. That is what my post is about and what that quote from the sun tutorial is also saying.
- 05-27-2010, 09:52 PM #5
Senior Member
- Join Date
- Mar 2009
- Location
- USA
- Posts
- 127
- Rep Power
- 0
Similar Threads
-
Hibernate Queries
By rummy in forum Advanced JavaReplies: 3Last Post: 01-08-2010, 01:11 PM -
org.hibernate.ejb.Version <clinit> INFO: Hibernate EntityManager 3.2.0.CR1
By Heather in forum JDBCReplies: 2Last Post: 06-30-2007, 03:01 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks