Buggy code:
public void initialize ( Object proxy ) throws DataAccessException { } public Filter enableFilter ( String filterName ) throws IllegalStateException { } public void lock ( final Object entity , final LockMode lockMode ) throws DataAccessException { } public void lock ( final String entityName , final Object entity , final LockMode lockMode ) throws DataAccessException { } public Serializable save ( final Object entity ) throws DataAccessException { } public Serializable save ( final String entityName , final Object entity ) throws DataAccessException { } public void update ( Object entity ) throws DataAccessException { } public void update ( final Object entity , final LockMode lockMode ) throws DataAccessException { } public void update ( String entityName , Object entity ) throws DataAccessException { } public void update ( final String entityName , final Object entity , final LockMode lockMode ) throws DataAccessException { } public void saveOrUpdate ( final Object entity ) throws DataAccessException { } public void saveOrUpdate ( final String entityName , final Object entity ) throws DataAccessException { } public void saveOrUpdateAll ( final Collection entities ) throws DataAccessException { } public void replicate ( final Object entity , final ReplicationMode replicationMode ) throws DataAccessException { } public void replicate ( final String entityName , final Object entity , final ReplicationMode replicationMode ) throws DataAccessException { } public void persist ( final Object entity ) throws DataAccessException { } public void persist ( final String entityName , final Object entity ) throws DataAccessException { } public Object merge ( final Object entity ) throws DataAccessException { } public Object merge ( final String entityName , final Object entity ) throws DataAccessException { } public void delete ( Object entity ) throws DataAccessException { } public void delete ( final Object entity , final LockMode lockMode ) throws DataAccessException { } public void delete ( String entityName , Object entity ) throws DataAccessException { } public void delete ( final String entityName , final Object entity , final LockMode lockMode ) throws DataAccessException { } public void deleteAll ( final Collection entities ) throws DataAccessException { } public void flush ( ) throws DataAccessException { } public void clear ( ) throws DataAccessException { } public List find ( String queryString ) throws DataAccessException { } public List find ( String queryString , Object value ) throws DataAccessException { } public List find ( final String queryString , final Object ... values ) throws DataAccessException { } public List findByNamedParam ( String queryString , String paramName , Object value ) throws DataAccessException { } public List findByNamedParam ( final String queryString , final String [ ] paramNames , final Object [ ] values ) throws DataAccessException { } public List findByValueBean ( final String queryString , final Object valueBean ) throws DataAccessException { } public List findByNamedQuery ( String queryName ) throws DataAccessException { } public List findByNamedQuery ( String queryName , Object value ) throws DataAccessException { } public List findByNamedQuery ( final String queryName , final Object ... values ) throws DataAccessException { } public List findByNamedQueryAndNamedParam ( String queryName , String paramName , Object value ) throws DataAccessException { } public List findByNamedQueryAndNamedParam ( final String queryName , final String [ ] paramNames , final Object [ ] values ) throws DataAccessException { } public List findByNamedQueryAndValueBean ( final String queryName , final Object valueBean ) throws DataAccessException { } public List findByCriteria ( DetachedCriteria criteria ) throws DataAccessException { } public List findByCriteria ( final DetachedCriteria criteria , final int firstResult , final int maxResults ) throws DataAccessException { } public List findByExample ( Object exampleEntity ) throws DataAccessException { } public List findByExample ( String entityName , Object exampleEntity ) throws DataAccessException { } public List findByExample ( Object exampleEntity , int firstResult , int maxResults ) throws DataAccessException { } public List findByExample ( final String entityName , final Object exampleEntity , final int firstResult , final int maxResults ) throws DataAccessException { } public Iterator iterate ( String queryString ) throws DataAccessException { } public Iterator iterate ( String queryString , Object value ) throws DataAccessException { } public Iterator iterate ( final String queryString , final Object ... values ) throws DataAccessException { } public void closeIterator ( Iterator it ) throws DataAccessException { } public int bulkUpdate ( String queryString ) throws DataAccessException { } public int bulkUpdate ( String queryString , Object value ) throws DataAccessException { } public int bulkUpdate ( final String queryString , final Object ... values ) throws DataAccessException { } protected void checkWriteOperationAllowed ( Session session ) throws InvalidDataAccessApiUsageException { } protected void prepareQuery ( Query queryObject ) { } protected void prepareCriteria ( Criteria criteria ) { } protected void applyNamedParameterToQuery ( Query queryObject , String paramName , Object value ) throws HibernateException { } private class CloseSuppressingInvocationHandler implements InvocationHandler { private final Session target ; public CloseSuppressingInvocationHandler ( Session target ) { } public Object invoke ( Object proxy , Method method , Object [ ] args ) throws Throwable { if ( method . getName ( ) . equals ( "equals" ) ) { <START_BUG> return proxy == ( args [ 0 ] ) ? Boolean . TRUE : Boolean . FALSE ; <END_BUG> } else if ( method . getName ( ) . equals ( "hashCode" ) ) { return System . identityHashCode ( proxy ) ; } else if ( method . getName ( ) . equals ( "close" ) ) { return null ; } try { Object retVal = method . invoke ( this . target , args ) ; if ( retVal instanceof Query ) { prepareQuery ( ( ( Query ) ( retVal ) ) ) ; } if ( retVal instanceof Criteria ) { prepareCriteria ( ( ( Criteria ) ( retVal ) ) ) ; } return retVal ; } catch ( InvocationTargetException ex ) { throw ex . getTargetException ( ) ; } } } }

Fix:
return proxy == ( args [ 0 ] ) ;