Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

hibernate sql ²Ù×÷

@SuppressWarnings("unchecked")
    public List<ZxFunction> selectFunctionParentByUserId(final int userId) {
        try {
            final String sql = "select *  from zx_function where f_id in ( select distinct f.f_parent_id from zx_function f,zx_permission p where p.f_id = f.f_id and p.u_id = ?)";
            return (List<ZxFunction>) getHibernateTemplate().execute(new HibernateCallback(){
                public Object doInHibernate(Session session)
                    throws HibernateException, SQLException {
                SQLQuery query = session.createSQLQuery(sql).addEntity(ZxFunction.class);
                query.setInteger(0, 1);
                return query.list();
            }});
        } catch (Exception e) {
            CommonsLog4jUtil.printToConsole(e);
            CommonsLog4jUtil.error("FunctionDaoImpl public List<UserFunction> selectFunctionParentByUserId() Error:", e);
            return null;
        }
    }
@SuppressWarnings("unchecked")
    public List<UserFunction> selectFunction(final int userId) {
        try {
            final String sql = "select f.f_id as FId,&q


Ïà¹ØÎĵµ£º

OracleÖм¸¸ö¹ØÓÚÈÕÆÚ·½ÃæµÄSQLʵÀý

¡í1:È¡µÃµ±Ç°ÈÕÆÚÊDZ¾Ôµĵڼ¸ÖÜ
SQL> select to_char(sysdate,'YYYYMMDD W HH24:MI:SS') from
dual;

TO_CHAR(SYSDATE,'YY
-------------------
20030327 4 18:16:09

SQL> select to_char(sysdate,'W') from dual;

T
-
4 ......

SqlÊý¾ÝÓÅ»¯·½°¸

1¡¢Ê¹ÓÃË÷ÒýÀ´¸ü¿ìµØ±éÀú±í¡£
ȱʡÇé¿öϽ¨Á¢µÄË÷ÒýÊÇ·ÇȺ¼¯Ë÷Òý£¬µ«ÓÐʱËü²¢²»ÊÇ×î¼ÑµÄ¡£ÔÚ·ÇȺ¼¯Ë÷ÒýÏ£¬Êý¾ÝÔÚÎïÀíÉÏËæ»ú´æ·ÅÔÚÊý¾ÝÒ³ÉÏ¡£ºÏÀíµÄË÷ÒýÉè¼ÆÒª½¨Á¢ÔÚ¶Ô¸÷ÖÖ²éѯµÄ·ÖÎöºÍÔ¤²âÉÏ¡£
Ò»°ãÀ´Ëµ£º
a.ÓдóÁ¿Öظ´Öµ¡¢ÇÒ¾­³£Óз¶Î§²éѯ£¨ > ,< £¬> =,< =£©ºÍorder by¡¢group by·¢ÉúµÄÁУ¬¿É¿¼
Âǽ ......

SQL outputʹÓÃ

SQL°æ£º
alter proc testguo
(
    @cityid int,
    @cityname nvarchar(100) output
)
as
select @cityname =  city_name from BA_Hot_City where cityid = @cityid
select @cityname
go
declare @cityname nvarchar(100)
exec testguo 1,@cityname output
ÁíÒ»°æ£º
ht ......

¡¾×ª¡¿²ÉÓÃp6spyÍêÕûÏÔʾhibernateµÄSQLÓï¾ä

×÷ÕߣºÇñÑó
QQ£º1964477
    ËäÈ»ÔÚhibernateÖÐÓÐshow_sqlÑ¡Ïµ«ÊÇÏÔʾ³öÀ´µÄÓï¾ä´ó¶àÀàËÆ
    select * from xxx where value=?
    µ«ÊÇÓÐʱºòÎÒÃÇÐèÒªµÃµ½ÍêÕûµÄSQLÓï¾ä£¬Ôõô°ìÄØ£¿Ê¹ÓÃP6SPY¾Í¿ÉÒÔÍê³ÉÕâ¸öÈÎÎñ
    p6spyÊÇÒ»¸ö¿ªÔ´Èí¼þ£¬Ëü¿ÉÒÔ¸ú ......

¹ØÓÚSql´æ´¢¹ý³Ì


SQL ÖеĴ洢¹ý³Ì£º
1.ÔÚ½¨Á¢´æ´¢¹ý³Ì֮ǰ¼ì²éËùÃüÃûµÄ´æ´¢¹ý³ÌÊÇ·ñÓ¦¾­´æÔÚ¡££¨ÒòΪÈç¹ûͬÃû´æ´¢¹ý³ÌÒѾ­´æÔÚ£¬ÐµĴ洢¹ý³Ì½«²»±»½¨Á¢£©
if exists(select * from sysobject where name='proc name' and type='p')
drop proc proc name
   go
2.¶¨Òå´æ´¢¹ý³Ì
create proc test
@gradel int, --¶¨Òå±äÁ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ