0

Is there a way to force Hibernate not to use sp_execute?

Consider this code

String queryString = "SET DEADLOCK_PRIORITY LOW;";
SQLQuery query = session.createSQLQuery(queryString);
return query.executeUpdate();

It turns into sp_prepare, then sp_execute and that defeats the purpose: after executing this statement session deadlock priority is back to NORMAL

In .NET the following code would execute the statement directly and priority for the session stays LOW (as desired)

command = new SqlCommand("SET DEADLOCK_PRIORITY LOW", _Connection);
command.ExecuteNonQuery();

How to force Hibernate to send the statement in the same manner?

1
  • 1
    ORM's like hibernate have their limits. Once you reach them, it's best to abandon hibernate entirely, at least for the parts where you cross the limits.
    – Andomar
    Commented Dec 21, 2011 at 16:48

1 Answer 1

1

I found a way to accomplish that.

String statementText = "SET DEADLOCK_PRIORITY LOW;";
Statement s = session.connection().createStatement();
s.execute(statementText);

However, connection() is "deprecated and scheduled for removal in Hibernate 4.x" (discussed here)

Not the answer you're looking for? Browse other questions tagged or ask your own question.