Skip to content
Advertisement

Spring boot and jpa query @P0

I’m trying to run the following query

@Query(value = "INSERT INTO controllordinitest.dbo.Records(FSId, FSBlob) SELECT NEWID(), BulkColumn FROM OPENROWSET(BULK :path, SINGLE_BLOB) as f;", nativeQuery= true)
@Modifying
void saveFile(@Param(value="path") String path);

but I keep getting the syntax error @P0, I also tried not to use parameters but “?” and still not working, my guess is that the string is not placed under ” and it ends up just next to bulk, but as soon as I place the single quote I get the error that there is no file in :path.

I also tried to wrap the ? with parenthesis but no luck… even tried to change the hibernate dialog but no luck again…

It could be a possible duplicate of this but their solutions just don’t work

Advertisement

Answer

I think the cause of this problem is that JPA parameters are only allowed inside the WHERE clause of the query.

You can’t use the parameter at any place of the created query.

In your case you use them in FROM part FROM OPENROWSET(BULK :path, SINGLE_BLOB)

Advertisement