Hi Stliu,
What is a "Work" exactly in hibernate context?
I was trying to create a CDI producer to provide a datasource OR a connection to someone using like:
Code:
@Inject
DataSource dataSource
//OR
@Inject
Connection connection
that datasource/connection would have to come from the same context as an entityManager
so, using work, could I try something like this to obtain the connection?
Code:
@Inject
private EntityManager entityManager;
private Connection connection;
@Produces
public Connection getConnection() {
org.hibernate.Session session = entityManager.unwrap(Session.class);
session.doWork(new Work() {
public void execute(Connection con) throws SQLException {
connection = con;
}
});
return connection;
}
I feel that something is not in place. Besides that with I'm getting a weird exception when using this producer
http://pastie.org/2970661