0

Using @Query to execute a MySQL function

Using @Query to execute a MySQL function as follows

Here is an example that uses Spring Data @Query to execute a MySQL function that returns a string value. Let’s say we have a MySQL function that returns a predefined text.

MySQL Function

hello_world() returns ‘Hello World’ in German.

Using @Query

Using Spring Data, we can use @Query with nativeQuery = true.