update zhu set zhu.zhu_name = :newName where zhu.zhu_name = :oldName

解决方案 »

  1.   

    09:24:11,625  INFO Environment:456 - Hibernate 3.0rc1
    09:24:11,625  INFO Environment:469 - hibernate.properties not found
    09:24:11,625  INFO Environment:502 - using CGLIB reflection optimizer
    09:24:11,640  INFO Environment:532 - using JDK 1.4 java.sql.Timestamp handling
    09:24:11,640  INFO Configuration:1228 - configuring from resource: /hibernate.cfg.xml
    09:24:11,640  INFO Configuration:1199 - Configuration resource: /hibernate.cfg.xml
    09:24:11,859  INFO Configuration:439 - Mapping resource: liangfang/data/Bbs.hbm.xml
    09:24:12,062  INFO HbmBinder:256 - Mapping class: liangfang.data.Staf -> Staf
    09:24:12,093  INFO HbmBinder:256 - Mapping class: liangfang.data.Lei -> Lei
    09:24:12,093  INFO HbmBinder:256 - Mapping class: liangfang.data.Zhu -> Zhu
    09:24:12,109  INFO Configuration:1340 - Configured SessionFactory: null
    09:24:12,109  INFO Configuration:844 - processing extends queue
    09:24:12,109  INFO Configuration:848 - processing collection mappings
    09:24:12,109  INFO Configuration:857 - processing association property references
    09:24:12,109  INFO Configuration:884 - processing foreign key constraints
    09:24:12,265  INFO Dialect:89 - Using dialect: org.hibernate.dialect.SQLServerDialect
    09:24:12,281  INFO SettingsFactory:90 - Default batch fetch size: 1
    09:24:12,281  INFO SettingsFactory:94 - Generate SQL with comments: disabled
    09:24:12,281  INFO SettingsFactory:98 - Order SQL updates by primary key: disabled
    09:24:12,281  INFO SettingsFactory:273 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
    09:24:12,296  INFO ASTQueryTranslatorFactory:21 - Using ASTQueryTranslatorFactory
    09:24:12,296  INFO SettingsFactory:106 - Query language substitutions: {}
    09:24:12,296  INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
    09:24:12,312  INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 20
    09:24:12,312  INFO DriverManagerConnectionProvider:45 - autocommit mode: false
    09:24:12,312  INFO DriverManagerConnectionProvider:80 - using driver: net.sourceforge.jtds.jdbc.Driver at URL: jdbc:jtds:sqlserver://192.168.0.2:1433;DatabaseName=cscc
    09:24:12,312  INFO DriverManagerConnectionProvider:86 - connection properties: {user=sa, password=****}
    09:24:12,578  INFO SettingsFactory:156 - Scrollable result sets: enabled
    09:24:12,578  INFO SettingsFactory:164 - JDBC3 getGeneratedKeys(): enabled
    09:24:12,593  INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
    09:24:12,593  INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
    09:24:12,593  INFO SettingsFactory:176 - Automatic flush during beforeCompletion(): disabled
    09:24:12,593  INFO SettingsFactory:179 - Automatic session close at end of transaction: disabled
    09:24:12,593  INFO SettingsFactory:260 - Cache provider: org.hibernate.cache.EhCacheProvider
    09:24:12,609  INFO SettingsFactory:187 - Second-level cache: enabled
    09:24:12,609  INFO SettingsFactory:192 - Optimize cache for minimal puts: disabled
    09:24:12,609  INFO SettingsFactory:199 - Structured second-level cache entries: enabled
    09:24:12,609  INFO SettingsFactory:203 - Query cache: disabled
    09:24:12,609  INFO SettingsFactory:210 - Echoing all SQL to stdout
    09:24:12,609  INFO SettingsFactory:214 - Statistics: disabled
    09:24:12,609  INFO SettingsFactory:218 - Deleted entity synthetic identifier rollback: disabled
    09:24:12,609  INFO SettingsFactory:232 - Default entity-mode: pojo
    09:24:12,906  INFO SessionFactoryImpl:140 - building session factory
    09:24:13,703  INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
    09:24:13,703  INFO SessionFactoryImpl:366 - Checking 0 named queries
    09:24:13,921 ERROR parser:40 - *** ERROR: line 1:25: expecting DOT, found '='
    expecting DOT, found '=' near line 1, column 25 [update zhu set zhu_name = :newName where zhu_name = :oldName]
      

  2.   

    你没改过来吧,怎么还是update zhu set zhu_name = :newName where zhu_name = :oldName??提示不是说了么,要点号。
      

  3.   

    String hqlUpdate = "update zhu(是类名的哦) set name(类里面的字段名哦) = :newName where name(类里面的字段名哦) = :oldName";
    Query query = session.createQuery(hqlUpdate);
    query.setString("newName", newName);
    query.setString("oldName", oldName );
    int updatedEntities = query.executeUpdate();
    tx.commit();
    session.close();
    我刚刚测过,可以的了,你用一下!
      

  4.   

    a_faint_hope(有点明白) ( ) 信誉:100 ============
    还是不行呀? 是不是要在 *.hbm.xml 配置的
    ==========================================
    : sgdb(神天月晓) ( ) 信誉:121 
    怎样加点,可以详细点吗???我是初学的,可以详细点吗?
      

  5.   

    hibernate.properties not found 没有hibernate.properties这个文件吗?
      

  6.   

    请问一下楼主,我也是用的ms sql server,怎么配置才行啊?我一个人搞了半天,也没有搞定.