change hibernate session management and fix bugs of ValueType