There are two tables: bb_players and bb_player_skills. player skills table has one to one relation with bb_players, and also foreign key to bb_players.
Error happens at executing this code:
Query q = em.createNamedQuery(PlayerSkill.DELETE_SKILL_BY_PLAYER_ID);
q.setParameter("playerID", playerID);
q.executeUpdate();
The named query is:
@NamedQuery(name = PlayerSkill.DELETE_SKILL_BY_PLAYER_ID, query = "DELETE FROM PlayerSkill s " +
" WHERE s.player.id = :playerID")
The error from postgresql logs is:
ERROR,42601,"syntax error at or near ""cross""",,,,,,
"delete from bb_player_skills cross join bb_players player1_ where id=$1",30,,""
Is my named query wrong and how should I rewrite it?
It appears that this may be an open Hibernate issue depending on your Hibernate version.
From: https://hibernate.atlassian.net/browse/HHH-7314
Using a JPA Delete query with conditions requiring a join through Hibernate entity-manager generates invalid SQL for PostgreSQL. PostgreSQL cannot use CROSS JOIN in the FROM clause of a DELETE query.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With