Hibernate Update不会更新任何内容

时间:2010-03-04 08:37:50

标签: hibernate transactions

理论上,此代码应为用户设置新的锁定状态,并将其写入数据库:

transaction = sess.beginTransaction();
String hql = "update User set locked=:newLockStatus where principalId in (:userIds)";
Query query = sess.createQuery(hql);
query.setBoolean("newLockStatus", locked);
query.setParameterList("userIds", userIdList);
query.executeUpdate();
transaction.commit();

当我运行此代码时,我没有收到错误或异常或其他任何内容......但是当我之后读取这些用户的状态时,我发现他们的锁定状态没有改变。如果我直接连接到数据库,我看到同样的事情。我认为这意味着我没有缓存同步问题,但实际上存在:

  • 查询中的问题
  • Hibernate中的一个错误,使更新无法反映

有谁知道?

修改: 这是请求的日志输出(删除了大量噪声):

DEBUG org.hibernate.impl.SessionImpl - opened session at timestamp: 12676941899
TRACE o.h.e.def.DefaultLoadEventListener - loading entity: [User#100012]
TRACE o.h.e.def.DefaultLoadEventListener - attempting to resolve: [User#100012]
TRACE o.h.e.def.DefaultLoadEventListener - object not resolved in any cache: [User#100012]
TRACE o.h.p.entity.AbstractEntityPersister - Fetching entity: [User#100012]
DEBUG org.hibernate.loader.Loader - loading entity: [User#100012]
DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG org.hibernate.jdbc.ConnectionManager - opening JDBC connection
TRACE o.h.c.DriverManagerConnectionProvider - total checked-out connections: 0
TRACE o.h.c.DriverManagerConnectionProvider - using pooled JDBC connection, pool size: 0
DEBUG org.hibernate.SQL - select user0_.principalId as principa2_1_0_, user0_.displayName as displayN3_1_0_, user0_.locked as locked1_0_, user0_.XYZ as XYZ5_1_0_, user0_.ABC as ABC6_1_0_, user0_.DEF as DEF1_0_ from PRINCIPAL user0_ where user0_.principalId=? and user0_.TYPE='USER'
Hibernate: select user0_.principalId as principa2_1_0_, user0_.displayName as displayN3_1_0_, user0_.locked as locked1_0_, user0_.XYZ as XYZ5_1_0_, user0_.ABC as ABC6_1_0_, user0_.DEF as DEF1_0_ from PRINCIPAL user0_ where user0_.principalId=? and user0_.TYPE='USER'
TRACE org.hibernate.jdbc.AbstractBatcher - preparing statement
TRACE org.hibernate.type.StringType - binding '100012' to parameter: 1
DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
TRACE org.hibernate.loader.Loader - processing result set
DEBUG org.hibernate.loader.Loader - result set row: 0
DEBUG org.hibernate.loader.Loader - result row: EntityKey[User#100012]
TRACE org.hibernate.loader.Loader - Initializing object from ResultSet: [User#100012]
TRACE o.h.p.entity.AbstractEntityPersister - Hydrating entity: [User#100012]
TRACE org.hibernate.type.StringType - returning 'MURALI KRISHNA  PRASAD YELESWARAPU' as column: displayN3_1_0_
TRACE org.hibernate.type.BooleanType - returning 'false' as column: locked1_0_
DEBUG org.hibernate.type.EnumType - Returning 'DEF' as column DEF1_0_
TRACE org.hibernate.loader.Loader - done processing result set (1 rows)
DEBUG org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
TRACE org.hibernate.jdbc.AbstractBatcher - closing statement
TRACE org.hibernate.loader.Loader - total objects hydrated: 1
DEBUG org.hibernate.engine.TwoPhaseLoad - resolving associations for [User#100012]
TRACE o.h.engine.loading.LoadContexts - creating collection wrapper:[User.roles#100012]
DEBUG org.hibernate.engine.TwoPhaseLoad - done materializing entity [User#100012]
DEBUG o.h.e.StatefulPersistenceContext - initializing non-lazy collections
DEBUG org.hibernate.loader.Loader - done entity load
TRACE org.hibernate.jdbc.JDBCContext - after autocommit
DEBUG org.hibernate.jdbc.ConnectionManager - aggressively releasing JDBC connection
DEBUG org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
TRACE o.h.c.DriverManagerConnectionProvider - returning connection to pool, pool size: 1
DEBUG org.hibernate.jdbc.ConnectionManager - opening JDBC connection
TRACE o.h.c.DriverManagerConnectionProvider - total checked-out connections: 0
TRACE o.h.c.DriverManagerConnectionProvider - using pooled JDBC connection, pool size: 0
TRACE o.h.e.def.DefaultLoadEventListener - loading entity: [User#100000]
TRACE o.h.e.def.DefaultLoadEventListener - attempting to resolve: [User#100000]
TRACE o.h.e.def.DefaultLoadEventListener - object not resolved in any cache: [User#100000]
TRACE o.h.p.entity.AbstractEntityPersister - Fetching entity: [User#100000]
DEBUG org.hibernate.loader.Loader - loading entity: [User#100000]
DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG org.hibernate.SQL - select user0_.principalId as principa2_1_0_, user0_.displayName as displayN3_1_0_, user0_.locked as locked1_0_, user0_.XYZ as XYZ5_1_0_, user0_.ABC as ABC6_1_0_, user0_.DEF as DEF1_0_ from PRINCIPAL user0_ where user0_.principalId=? and user0_.TYPE='USER'
Hibernate: select user0_.principalId as principa2_1_0_, user0_.displayName as displayN3_1_0_, user0_.locked as locked1_0_, user0_.XYZ as XYZ5_1_0_, user0_.ABC as ABC6_1_0_, user0_.DEF as DEF1_0_ from PRINCIPAL user0_ where user0_.principalId=? and user0_.TYPE='USER'
TRACE org.hibernate.jdbc.AbstractBatcher - preparing statement
TRACE org.hibernate.type.StringType - binding '100000' to parameter: 1
DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
TRACE org.hibernate.loader.Loader - processing result set
DEBUG org.hibernate.loader.Loader - result set row: 0
DEBUG org.hibernate.loader.Loader - result row: EntityKey[User#100000]
TRACE org.hibernate.loader.Loader - Initializing object from ResultSet: [User#100000]
TRACE o.h.p.entity.AbstractEntityPersister - Hydrating entity: [User#100000]
TRACE org.hibernate.type.StringType - returning 'SHAMLAL AGGARWAL' as column: displayN3_1_0_
TRACE org.hibernate.type.BooleanType - returning 'false' as column: locked1_0_
DEBUG org.hibernate.type.EnumType - Returning 'DEF' as column DEF1_0_
TRACE org.hibernate.loader.Loader - done processing result set (1 rows)
DEBUG org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
TRACE org.hibernate.jdbc.AbstractBatcher - closing statement
TRACE org.hibernate.loader.Loader - total objects hydrated: 1
DEBUG org.hibernate.engine.TwoPhaseLoad - resolving associations for [User#100000]
TRACE o.h.engine.loading.LoadContexts - creating collection wrapper:[User.roles#100000]
DEBUG org.hibernate.engine.TwoPhaseLoad - done materializing entity [User#100000]
DEBUG o.h.e.StatefulPersistenceContext - initializing non-lazy collections
DEBUG org.hibernate.loader.Loader - done entity load
TRACE org.hibernate.jdbc.JDBCContext - after autocommit
DEBUG org.hibernate.jdbc.ConnectionManager - aggressively releasing JDBC connection
DEBUG org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
TRACE o.h.c.DriverManagerConnectionProvider - returning connection to pool, pool size: 1
DEBUG org.hibernate.jdbc.ConnectionManager - opening JDBC connection
TRACE o.h.c.DriverManagerConnectionProvider - total checked-out connections: 0
TRACE o.h.c.DriverManagerConnectionProvider - using pooled JDBC connection, pool size: 0
DEBUG o.h.transaction.JDBCTransaction - begin
DEBUG o.h.transaction.JDBCTransaction - current autocommit status: false
TRACE org.hibernate.jdbc.JDBCContext - after transaction begin
TRACE o.h.engine.query.QueryPlanCache - unable to locate HQL query plan in cache; generating (update User set locked = :newLockStatus where principalId in (:userIds))
DEBUG o.h.hql.ast.QueryTranslatorImpl - parse() - HQL: update User set locked = :newLockStatus where principalId in (:userIds)
DEBUG org.hibernate.hql.ast.AST - --- HQL AST ---
 \-[UPDATE] 'update'
    +-[FROM] 'FROM'
    |  \-[RANGE] 'RANGE'
    |     \-[DOT] '.'
    |        +-[DOT] '.'
    |        |  +-[DOT] '.'
    |        |  |  +-[DOT] '.'
    |        |  |  |  +-[DOT] '.'
    |        |  |  |  |  +-[DOT] '.'
    |        |  |  |  |  |  +-[IDENT] 'X'
    |        |  |  |  |  |  \-[IDENT] 'X'
    |        |  |  |  |  \-[IDENT] 'X'
    |        |  |  |  \-[IDENT] 'X'
    |        |  |  \-[IDENT] 'X'
    |        |  \-[IDENT] 'X'
    |        \-[IDENT] 'User'
    +-[SET] 'set'
    |  \-[EQ] '='
    |     +-[IDENT] 'locked'
    |     \-[COLON] ':'
    |        \-[IDENT] 'newLockStatus'
    \-[WHERE] 'where'
       \-[IN] 'in'
          +-[IDENT] 'principalId'
          \-[IN_LIST] 'inList'
             \-[COLON] ':'
                \-[IDENT] 'userIds'

DEBUG org.hibernate.hql.ast.ErrorCounter - throwQueryException() : no errors
TRACE org.hibernate.hql.ast.HqlSqlWalker - -> statement (update [UPDATE])
TRACE org.hibernate.hql.ast.HqlSqlWalker - ---> updateStatement (update [UPDATE])
DEBUG o.h.hql.antlr.HqlSqlBaseWalker - update << begin [level=1, statement=update]
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----> fromClause (FROM [FROM])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -------> fromElementList (RANGE [RANGE])
TRACE org.hibernate.hql.ast.HqlSqlWalker - ---------> fromElement (RANGE [RANGE])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----------> path (. [DOT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -------------> path (. [DOT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - ---------------> path (. [DOT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----------------> path (. [DOT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -------------------> path (. [DOT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - ---------------------> path (. [DOT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----------------------> path (X [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -------------------------> identifier (X [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - <------------------------- identifier
TRACE org.hibernate.hql.ast.HqlSqlWalker - <----------------------- path
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----------------------> identifier (X [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - <----------------------- identifier
TRACE org.hibernate.hql.ast.HqlSqlWalker - <--------------------- path
TRACE org.hibernate.hql.ast.HqlSqlWalker - ---------------------> identifier (X [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - <--------------------- identifier
TRACE org.hibernate.hql.ast.HqlSqlWalker - <------------------- path
TRACE org.hibernate.hql.ast.HqlSqlWalker - -------------------> identifier (X [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - <------------------- identifier
TRACE org.hibernate.hql.ast.HqlSqlWalker - <----------------- path
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----------------> identifier (X [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - <----------------- identifier
TRACE org.hibernate.hql.ast.HqlSqlWalker - <--------------- path
TRACE org.hibernate.hql.ast.HqlSqlWalker - ---------------> identifier (X [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - <--------------- identifier
TRACE org.hibernate.hql.ast.HqlSqlWalker - <------------- path
TRACE org.hibernate.hql.ast.HqlSqlWalker - -------------> identifier (User [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - <------------- identifier
TRACE org.hibernate.hql.ast.HqlSqlWalker - <----------- path
DEBUG o.hibernate.hql.ast.tree.FromElement - FromClause{level=1} :  User (no alias) -> user0_
TRACE org.hibernate.hql.ast.HqlSqlWalker - <--------- fromElement
TRACE org.hibernate.hql.ast.HqlSqlWalker - <------- fromElementList
TRACE org.hibernate.hql.ast.HqlSqlWalker - <----- fromClause
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----> setClause (set [SET])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -------> assignment (= [EQ])
TRACE org.hibernate.hql.ast.HqlSqlWalker - ---------> propertyRef (locked [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----------> identifier (locked [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - <----------- identifier
TRACE org.hibernate.hql.ast.HqlSqlWalker - attempting to resolve property [locked] as a non-qualified ref
DEBUG o.h.hql.ast.tree.FromReferenceNode - Resolved :  {synthetic-alias} -> {synthetic-alias}
TRACE o.hibernate.hql.ast.tree.FromElement - handling property dereference [User (null) -> locked (class)]
TRACE org.hibernate.hql.ast.HqlSqlWalker - <--------- propertyRef
DEBUG org.hibernate.hql.ast.tree.DotNode - getDataType() : locked -> org.hibernate.type.BooleanType@1fe4169
TRACE o.h.hql.ast.tree.FromElementType - Using non-qualified column reference [locked -> ([locked])]
DEBUG o.h.hql.ast.tree.FromReferenceNode - Resolved :  {synthetic-alias}.locked -> locked
TRACE org.hibernate.hql.ast.HqlSqlWalker - ---------> newValue (: [COLON])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----------> expr (: [COLON])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -------------> parameter (: [COLON])
TRACE org.hibernate.hql.ast.HqlSqlWalker - ---------------> identifier (newLockStatus [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - <--------------- identifier
TRACE org.hibernate.hql.ast.HqlSqlWalker - <------------- parameter
TRACE org.hibernate.hql.ast.HqlSqlWalker - <----------- expr
TRACE org.hibernate.hql.ast.HqlSqlWalker - <--------- newValue
TRACE org.hibernate.hql.ast.HqlSqlWalker - <------- assignment
TRACE org.hibernate.hql.ast.HqlSqlWalker - <----- setClause
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----> whereClause (where [WHERE])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -------> logicalExpr (in [IN])
TRACE org.hibernate.hql.ast.HqlSqlWalker - ---------> comparisonExpr (in [IN])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----------> exprOrSubquery (principalId [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -------------> expr (principalId [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - ---------------> addrExpr (principalId [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----------------> identifier (principalId [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - <----------------- identifier
TRACE org.hibernate.hql.ast.HqlSqlWalker - attempting to resolve property [principalId] as a non-qualified ref
DEBUG o.h.hql.ast.tree.FromReferenceNode - Resolved :  {synthetic-alias} -> {synthetic-alias}
TRACE o.hibernate.hql.ast.tree.FromElement - handling property dereference [User (null) -> principalId (class)]
TRACE org.hibernate.hql.ast.HqlSqlWalker - <--------------- addrExpr
DEBUG org.hibernate.hql.ast.tree.DotNode - getDataType() : principalId -> org.hibernate.type.StringType@f42160
TRACE o.h.hql.ast.tree.FromElementType - Using non-qualified column reference [principalId -> ([principalId])]
DEBUG o.h.hql.ast.tree.FromReferenceNode - Resolved :  {synthetic-alias}.principalId -> principalId
TRACE org.hibernate.hql.ast.HqlSqlWalker - <------------- expr
TRACE org.hibernate.hql.ast.HqlSqlWalker - <----------- exprOrSubquery
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----------> inRhs (inList [IN_LIST])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -------------> expr (: [COLON])
TRACE org.hibernate.hql.ast.HqlSqlWalker - ---------------> parameter (: [COLON])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----------------> identifier (userIds [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - <----------------- identifier
TRACE org.hibernate.hql.ast.HqlSqlWalker - <--------------- parameter
TRACE org.hibernate.hql.ast.HqlSqlWalker - <------------- expr
TRACE org.hibernate.hql.ast.HqlSqlWalker - <----------- inRhs
TRACE org.hibernate.hql.ast.HqlSqlWalker - <--------- comparisonExpr
TRACE org.hibernate.hql.ast.HqlSqlWalker - <------- logicalExpr
TRACE org.hibernate.hql.ast.HqlSqlWalker - <----- whereClause
DEBUG o.h.hql.antlr.HqlSqlBaseWalker - update : finishing up [level=1, statement=update]
DEBUG o.h.hql.antlr.HqlSqlBaseWalker - update >> end [level=1, statement=update]
TRACE org.hibernate.hql.ast.HqlSqlWalker - <--- updateStatement
TRACE org.hibernate.hql.ast.HqlSqlWalker - <- statement
DEBUG org.hibernate.hql.ast.AST - --- SQL AST ---
 \-[UPDATE] UpdateStatement: 'update'  querySpaces (PRINCIPAL)
    +-[FROM] FromClause: 'FROM' FromClause{level=1, fromElementCounter=1, fromElements=1, fromElementByClassAlias=[], fromElementByTableAlias=[user0_], fromElementsByPath=[], collectionJoinFromElementsByPath=[], impliedElements=[]}
    |  \-[FROM_FRAGMENT] FromElement: 'PRINCIPAL' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=PRINCIPAL,tableAlias=user0_,origin=null,colums={,className=User}}
    +-[SET] SqlNode: 'set'
    |  \-[EQ] BinaryLogicOperatorNode: '='
    |     +-[DOT] DotNode: 'locked'
    |     |  +-[IDENT] IdentNode: '{synthetic-alias}'
    |     |  \-[IDENT] IdentNode: 'locked'
    |     \-[NAMED_PARAM] ParameterNode: '?' {name=newLockStatus, expectedType=org.hibernate.type.BooleanType@1fe4169}
    \-[WHERE] SqlNode: 'where'
       \-[AND] SqlNode: '{and}'
          +-[SQL_TOKEN] SqlFragment: 'TYPE='USER''
          \-[IN] InLogicOperatorNode: 'in'
             +-[DOT] DotNode: 'principalId'
             |  +-[IDENT] IdentNode: '{synthetic-alias}'
             |  \-[IDENT] IdentNode: 'principalId'
             \-[IN_LIST] SqlNode: 'inList'
                \-[NAMED_PARAM] ParameterNode: '?' {name=userIds, expectedType=org.hibernate.type.StringType@f42160}

DEBUG org.hibernate.hql.ast.ErrorCounter - throwQueryException() : no errors
TRACE org.hibernate.hql.ast.SqlGenerator - -> statement (update [UPDATE])
TRACE org.hibernate.hql.ast.SqlGenerator - ---> updateStatement (update [UPDATE])
TRACE org.hibernate.hql.ast.SqlGenerator - -----> fromTable (PRINCIPAL [FROM_FRAGMENT])
TRACE org.hibernate.hql.ast.SqlGenerator - <----- fromTable
TRACE org.hibernate.hql.ast.SqlGenerator - -----> setClause (set [SET])
TRACE org.hibernate.hql.ast.SqlGenerator - -------> comparisonExpr (= [EQ])
TRACE org.hibernate.hql.ast.SqlGenerator - ---------> binaryComparisonExpression (= [EQ])
TRACE org.hibernate.hql.ast.SqlGenerator - -----------> expr (locked [DOT])
TRACE org.hibernate.hql.ast.SqlGenerator - -------------> simpleExpr (locked [DOT])
TRACE org.hibernate.hql.ast.SqlGenerator - ---------------> addrExpr (locked [DOT])
TRACE org.hibernate.hql.ast.SqlGenerator - <--------------- addrExpr
TRACE org.hibernate.hql.ast.SqlGenerator - <------------- simpleExpr
TRACE org.hibernate.hql.ast.SqlGenerator - <----------- expr
TRACE org.hibernate.hql.ast.SqlGenerator - -----------> expr (? [NAMED_PARAM])
TRACE org.hibernate.hql.ast.SqlGenerator - -------------> simpleExpr (? [NAMED_PARAM])
TRACE org.hibernate.hql.ast.SqlGenerator - ---------------> parameter (? [NAMED_PARAM])
TRACE org.hibernate.hql.ast.SqlGenerator - <--------------- parameter
TRACE org.hibernate.hql.ast.SqlGenerator - <------------- simpleExpr
TRACE org.hibernate.hql.ast.SqlGenerator - <----------- expr
TRACE org.hibernate.hql.ast.SqlGenerator - <--------- binaryComparisonExpression
TRACE org.hibernate.hql.ast.SqlGenerator - <------- comparisonExpr
TRACE org.hibernate.hql.ast.SqlGenerator - <----- setClause
TRACE org.hibernate.hql.ast.SqlGenerator - -----> whereClause (where [WHERE])
TRACE org.hibernate.hql.ast.SqlGenerator - -------> whereClauseExpr ({and} [AND])
TRACE org.hibernate.hql.ast.SqlGenerator - ---------> booleanExpr ({and} [AND])
TRACE org.hibernate.hql.ast.SqlGenerator - -----------> booleanOp ({and} [AND])
TRACE org.hibernate.hql.ast.SqlGenerator - -------------> booleanExpr (TYPE='USER' [SQL_TOKEN])
TRACE org.hibernate.hql.ast.SqlGenerator - <------------- booleanExpr
TRACE org.hibernate.hql.ast.SqlGenerator - -------------> booleanExpr (in [IN])
TRACE org.hibernate.hql.ast.SqlGenerator - ---------------> comparisonExpr (in [IN])
TRACE org.hibernate.hql.ast.SqlGenerator - -----------------> exoticComparisonExpression (in [IN])
TRACE org.hibernate.hql.ast.SqlGenerator - -------------------> expr (principalId [DOT])
TRACE org.hibernate.hql.ast.SqlGenerator - ---------------------> simpleExpr (principalId [DOT])
TRACE org.hibernate.hql.ast.SqlGenerator - -----------------------> addrExpr (principalId [DOT])
TRACE org.hibernate.hql.ast.SqlGenerator - <----------------------- addrExpr
TRACE org.hibernate.hql.ast.SqlGenerator - <--------------------- simpleExpr
TRACE org.hibernate.hql.ast.SqlGenerator - <------------------- expr
TRACE org.hibernate.hql.ast.SqlGenerator - -------------------> inList (inList [IN_LIST])
TRACE org.hibernate.hql.ast.SqlGenerator - ---------------------> simpleExprList (? [NAMED_PARAM])
TRACE org.hibernate.hql.ast.SqlGenerator - -----------------------> simpleExpr (? [NAMED_PARAM])
TRACE org.hibernate.hql.ast.SqlGenerator - -------------------------> parameter (? [NAMED_PARAM])
TRACE org.hibernate.hql.ast.SqlGenerator - <------------------------- parameter
TRACE org.hibernate.hql.ast.SqlGenerator - <----------------------- simpleExpr
TRACE org.hibernate.hql.ast.SqlGenerator - <--------------------- simpleExprList
TRACE org.hibernate.hql.ast.SqlGenerator - <------------------- inList
TRACE org.hibernate.hql.ast.SqlGenerator - <----------------- exoticComparisonExpression
TRACE org.hibernate.hql.ast.SqlGenerator - <--------------- comparisonExpr
TRACE org.hibernate.hql.ast.SqlGenerator - <------------- booleanExpr
TRACE org.hibernate.hql.ast.SqlGenerator - <----------- booleanOp
TRACE org.hibernate.hql.ast.SqlGenerator - <--------- booleanExpr
TRACE org.hibernate.hql.ast.SqlGenerator - <------- whereClauseExpr
TRACE org.hibernate.hql.ast.SqlGenerator - <----- whereClause
TRACE org.hibernate.hql.ast.SqlGenerator - <--- updateStatement
TRACE org.hibernate.hql.ast.SqlGenerator - <- statement
DEBUG org.hibernate.hql.ast.ErrorCounter - throwQueryException() : no errors
TRACE o.h.engine.query.HQLQueryPlan - HQL param location recognition took 0 mills (update User set locked = :newLockStatus where principalId in (:userIds))
TRACE o.h.engine.query.QueryPlanCache - unable to locate HQL query plan in cache; generating (update User set locked = :newLockStatus where principalId in (:userIds0_, :userIds1_))
DEBUG o.h.hql.ast.QueryTranslatorImpl - parse() - HQL: update User set locked = :newLockStatus where principalId in (:userIds0_, :userIds1_)
DEBUG org.hibernate.hql.ast.AST - --- HQL AST ---
 \-[UPDATE] 'update'
    +-[FROM] 'FROM'
    |  \-[RANGE] 'RANGE'
    |     \-[DOT] '.'
    |        +-[DOT] '.'
    |        |  +-[DOT] '.'
    |        |  |  +-[DOT] '.'
    |        |  |  |  +-[DOT] '.'
    |        |  |  |  |  +-[DOT] '.'
    |        |  |  |  |  |  +-[IDENT] 'X'
    |        |  |  |  |  |  \-[IDENT] 'X'
    |        |  |  |  |  \-[IDENT] 'X'
    |        |  |  |  \-[IDENT] 'X'
    |        |  |  \-[IDENT] 'X'
    |        |  \-[IDENT] 'X'
    |        \-[IDENT] 'User'
    +-[SET] 'set'
    |  \-[EQ] '='
    |     +-[IDENT] 'locked'
    |     \-[COLON] ':'
    |        \-[IDENT] 'newLockStatus'
    \-[WHERE] 'where'
       \-[IN] 'in'
          +-[IDENT] 'principalId'
          \-[IN_LIST] 'inList'
             +-[COLON] ':'
             |  \-[IDENT] 'userIds0_'
             \-[COLON] ':'
                \-[IDENT] 'userIds1_'

DEBUG org.hibernate.hql.ast.ErrorCounter - throwQueryException() : no errors
TRACE org.hibernate.hql.ast.HqlSqlWalker - -> statement (update [UPDATE])
TRACE org.hibernate.hql.ast.HqlSqlWalker - ---> updateStatement (update [UPDATE])
DEBUG o.h.hql.antlr.HqlSqlBaseWalker - update << begin [level=1, statement=update]
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----> fromClause (FROM [FROM])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -------> fromElementList (RANGE [RANGE])
TRACE org.hibernate.hql.ast.HqlSqlWalker - ---------> fromElement (RANGE [RANGE])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----------> path (. [DOT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -------------> path (. [DOT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - ---------------> path (. [DOT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----------------> path (. [DOT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -------------------> path (. [DOT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - ---------------------> path (. [DOT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----------------------> path (X [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -------------------------> identifier (X [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - <------------------------- identifier
TRACE org.hibernate.hql.ast.HqlSqlWalker - <----------------------- path
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----------------------> identifier (X [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - <----------------------- identifier
TRACE org.hibernate.hql.ast.HqlSqlWalker - <--------------------- path
TRACE org.hibernate.hql.ast.HqlSqlWalker - ---------------------> identifier (X [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - <--------------------- identifier
TRACE org.hibernate.hql.ast.HqlSqlWalker - <------------------- path
TRACE org.hibernate.hql.ast.HqlSqlWalker - -------------------> identifier (X [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - <------------------- identifier
TRACE org.hibernate.hql.ast.HqlSqlWalker - <----------------- path
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----------------> identifier (X [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - <----------------- identifier
TRACE org.hibernate.hql.ast.HqlSqlWalker - <--------------- path
TRACE org.hibernate.hql.ast.HqlSqlWalker - ---------------> identifier (X [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - <--------------- identifier
TRACE org.hibernate.hql.ast.HqlSqlWalker - <------------- path
TRACE org.hibernate.hql.ast.HqlSqlWalker - -------------> identifier (User [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - <------------- identifier
TRACE org.hibernate.hql.ast.HqlSqlWalker - <----------- path
DEBUG o.hibernate.hql.ast.tree.FromElement - FromClause{level=1} :  User (no alias) -> user0_
TRACE org.hibernate.hql.ast.HqlSqlWalker - <--------- fromElement
TRACE org.hibernate.hql.ast.HqlSqlWalker - <------- fromElementList
TRACE org.hibernate.hql.ast.HqlSqlWalker - <----- fromClause
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----> setClause (set [SET])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -------> assignment (= [EQ])
TRACE org.hibernate.hql.ast.HqlSqlWalker - ---------> propertyRef (locked [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----------> identifier (locked [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - <----------- identifier
TRACE org.hibernate.hql.ast.HqlSqlWalker - attempting to resolve property [locked] as a non-qualified ref
DEBUG o.h.hql.ast.tree.FromReferenceNode - Resolved :  {synthetic-alias} -> {synthetic-alias}
TRACE o.hibernate.hql.ast.tree.FromElement - handling property dereference [User (null) -> locked (class)]
TRACE org.hibernate.hql.ast.HqlSqlWalker - <--------- propertyRef
DEBUG org.hibernate.hql.ast.tree.DotNode - getDataType() : locked -> org.hibernate.type.BooleanType@1fe4169
TRACE o.h.hql.ast.tree.FromElementType - Using non-qualified column reference [locked -> ([locked])]
DEBUG o.h.hql.ast.tree.FromReferenceNode - Resolved :  {synthetic-alias}.locked -> locked
TRACE org.hibernate.hql.ast.HqlSqlWalker - ---------> newValue (: [COLON])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----------> expr (: [COLON])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -------------> parameter (: [COLON])
TRACE org.hibernate.hql.ast.HqlSqlWalker - ---------------> identifier (newLockStatus [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - <--------------- identifier
TRACE org.hibernate.hql.ast.HqlSqlWalker - <------------- parameter
TRACE org.hibernate.hql.ast.HqlSqlWalker - <----------- expr
TRACE org.hibernate.hql.ast.HqlSqlWalker - <--------- newValue
TRACE org.hibernate.hql.ast.HqlSqlWalker - <------- assignment
TRACE org.hibernate.hql.ast.HqlSqlWalker - <----- setClause
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----> whereClause (where [WHERE])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -------> logicalExpr (in [IN])
TRACE org.hibernate.hql.ast.HqlSqlWalker - ---------> comparisonExpr (in [IN])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----------> exprOrSubquery (principalId [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -------------> expr (principalId [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - ---------------> addrExpr (principalId [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - -----------------> identifier (principalId [IDENT])
TRACE org.hibernate.hql.ast.HqlSqlWalker - <----------------- identifier
TRACE org.hibernate.hql.ast.HqlSqlWalker - attempting to resolve property [principalId] as a non-qualified ref
D

2 个答案:

答案 0 :(得分:1)

你有没有打电话给sess.flush()和sess.close()?

答案 1 :(得分:0)

您是否碰巧拥有版本列?当具有Version列(名为X且当前值为Y)时,Hibernate添加“SET X = Y + 1 WHERE X = Y”。这可能是您记录未更新的原因,因为它与条件不匹配。 我建议打开日志,这样你就可以看到Hibernate生成的实际Update语句。

希望它有所帮助。