1

I have a simple named query . We did an upgrade of hibernate libraries and we are seeing the following error . It was working fine in previous version.

Any reason why simple query fails like this ?

    Caused by: org.hibernate.exception.GenericJDBCException: could not execute query
        at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140) [hibernate3.jar:]
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128) [hibernate3.jar:]
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) [hibernate3.jar:]
        at org.hibernate.loader.Loader.doList(Loader.java:2545) [hibernate3.jar:]
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276) [hibernate3.jar:]
        at org.hibernate.loader.Loader.list(Loader.java:2271) [hibernate3.jar:]
        at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:459) [hibernate3.jar:]
        at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:365) [hibernate3.jar:]
        at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196) [hibernate3.jar:]
        at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268) [hibernate3.jar:]
        at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102) [hibernate3.jar:]
        at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:246) [hibernate3.jar:]
        ... 157 more
Caused by: java.sql.SQLException: java.lang.IllegalArgumentException: Negative delay

Hibernate version is 3 and the code is like below

String selectSql = "select m from UserEntity m";
try {
    Query query = entityManager.createQuery(selectSql);
    Collection<UserEntity> userentities = (Collection<UserEntity>) query.getResultList();

}...

7
  • 1
    What Hibernate versions? What query? Some more information would be beneficial. Commented May 6, 2015 at 9:57
  • thanks i have updated the question with the details , Commented May 6, 2015 at 10:10
  • Does the query do what you want with select m.*? Commented May 6, 2015 at 10:15
  • @GordonLinoff yeah , we want to query all the entities in this query. yeah this is expected query Commented May 6, 2015 at 10:58
  • 1
    from UserEntity m might work Commented May 6, 2015 at 11:09

2 Answers 2

1

I am encountering the same "Negative delay" exception. Based on my investigation so far, it appears to be due to the JCA layer passing Integer.MAX_VALUE as a query timeout to the MySQL driver. The MySQL driver later mutiplies this by 1000 to convert it into milliseconds, which overflows into a negative value and triggers the "Negative delay" exception when used as a parameter for a java.util.Timer schedule() call. I'm not sure why JBoss is using Integer.MAX_VALUE in the particular scenario where this problem occurs, since I have specified an explicit timeout in the datasource XML configuration. One thing to note is that this problem is only observed after a slave node joins the JBoss cluster. Before that, when only the master node is running, the same workflow that invokes the query completes successfully.

Sign up to request clarification or add additional context in comments.

Comments

1

The exact issue seems to be in the way transactions are propagated while making EJB calls using remote EJB client context lookup. If the caller is in a transaction the remote call ends up getting an invalid value, in this case Integer.MAX_VALUE, for transaction timeout in the JTA layer. Therefore when the JCA layer tries to configure transaction timeout based on JTA transaction timeout it ends up passing this huge value to JDBC. I think this is a recent bug in Jboss 6.3 EAP since I haven't seen it in previous versions.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.