开发者

Hibernate Update does Not Update Anything

In theory, this code should set the new lock status to the users and get that written to the database:

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();

When I run this code, I don't get an error or an exception or anything... but when I read the status of these users afterwards, I see that their lock status is unchanged. If I connect directly to the database, I see the same thing. I interpret that as meaning that I'm not having a cache synchronization issue, but really that there is either:

  • a problem in the query
  • a bug in Hibernate such that the update doesn't get reflected

Anyone knows?

EDIT: Here is the log output (with lots of noise removed) as requested:

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 (princi开发者_如何转开发palId [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


Did you call sess.flush() and sess.close()?


Do you happen to have a Version column? When having a Version column (named X with current value of Y), Hibernate adds "SET X = Y + 1 WHERE X = Y". It may be the reason why you record isn't updated because it doesn't match the condition. I recommend turning the log on, so you can see the actual Update statement Hibernate generates.

Hope it helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜