Image

Imagealamar wrote in Imageru_java

Hibernate: два бага, что я не так делаю.

Сегодня попробовал использовать Hibernateовые DML.


Почему-то из HQL:
Delete from Goods g where g.section in (Select s.descendants from GoodsSection s where s.outerId = :outerId)
получился такой SQL:
delete from goods where section_id in (select . from goods_section goodssecti1_, goods_section_asc_or_self descendant2_, goods_section goodssecti3_ where goodssecti1_.id=descendant2_.goods_section_asc_or_self_id and descendant2_.goods_section_id=goodssecti3_.id and goodssecti1_.outer_id=?)

Более того, из HQL:
Delete from Goods g where g.section in (Select dsc from GoodsSection s join s.descendants dsc where s.outerId = :outerId)
получился такой SQL:
delete from goods where section_id in (select id from goods_section goodssecti1_ inner join goods_section_asc_or_self descendant2_ on goodssecti1_.id=descendant2_.goods_section_asc_or_self_id inner join goods_section goodssecti3_ on descendant2_.goods_section_id=goodssecti3_.id where goodssecti1_.outer_id=?)
NB: Естественно, id был и у таблицы goods_section, и у таблицы goods_section_asc_or_self, и получилась ошибка SQL-синтаксиса.


Хотелось бы понять, как из факта, что из достаточно тривиального и не содержащего явных ошибок HQL получается некорректный SQL, следует, что Hibernate - отличная библиотека и у вас с ней проблем никогда не было?