0

I'm using JPA / EclipseLink for Database-Access. Within my MySQL-Database I need to seet the Parameter group_concat_max_len to a larger number. Can I do this with JPA?

I tried it with the following statement:

Query query = em.createNativeQuery("SET  group_concat_max_len = 10240;");

But this throws an java.lang.IllegalStateException: Invalid call on a query that does not return result sets.

Can somebody help?

Thanks Bernhard

Mikko Maunu
  • 41,366
  • 10
  • 132
  • 135
stoi
  • 61
  • 1
  • 6

1 Answers1

0

Line of code that causes error is missing from the question. Following does not throw described exception:

Query query = em.createNativeQuery("SET  group_concat_max_len = 10240;");

But if created instance of Query is used as follows, then exception will be thrown:

query.getResultList();
//or 
query.getSingleResult();

Solution is to call executeUpdate method instead of ones above:

query.executeUpdate();
Mikko Maunu
  • 41,366
  • 10
  • 132
  • 135
  • Hi, thanks for help, now after embedding the executeUpdate in a transaction, it worked. – stoi Sep 23 '13 at 19:25