private NamedQueryDefinition extractHqlQueryDefinition(
     org.hibernate.Query hqlQuery, String name) {
   final NamedQueryDefinitionBuilder builder = new NamedQueryDefinitionBuilder(name);
   fillInNamedQueryBuilder(builder, hqlQuery);
   // LockOptions only valid for HQL/JPQL queries...
   builder.setLockOptions(hqlQuery.getLockOptions().makeCopy());
   return builder.createNamedQueryDefinition();
 }
 private void fillInNamedQueryBuilder(
     NamedQueryDefinitionBuilder builder, org.hibernate.Query query) {
   builder
       .setQuery(query.getQueryString())
       .setComment(query.getComment())
       .setCacheable(query.isCacheable())
       .setCacheRegion(query.getCacheRegion())
       .setCacheMode(query.getCacheMode())
       .setTimeout(query.getTimeout())
       .setFetchSize(query.getFetchSize())
       .setFirstResult(query.getFirstResult())
       .setMaxResults(query.getMaxResults())
       .setReadOnly(query.isReadOnly())
       .setFlushMode(query.getFlushMode());
 }