I am pumping existing JDBC connection using SessionFactory.openSession(Connection). Now in 4.0 this method is not available. Which method should I use for this?
SessionFactory.openSession(Connection)
You can use SessionFactory.withOptions() and SessionBuilder.connection(Connection connection).
SessionBuilder connection(Connection connection)
Adds a specific connection to the session options Parameters: connection - The connection to use. Returns: this, for method chaining
Adds a specific connection to the session options
Parameters: connection - The connection to use.
Returns: this, for method chaining
Example:
SessionBuilder sb = SessionFactory.withOptions(); Session session = sb.connection(connection).openSession();
2.1m questions
2.1m answers
60 comments
57.0k users