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 sintax 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 erroe 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 dupplicate of this but their solutions just don't work
CodePudding user response:
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)