Problem because I use Query for delete
(getSessionFactory().getCurrentSession().createQuery...).
Is there a way to define cascade delete in HQL ?
Thanks.
ros wrote:
>
> Hi!
>
> How to setup cascade delete using JPA annontation?
>
> For example we have Purchase one-to-many Item pojos.
>
> In purchase definition of item link
>
> @OneToMany(targetEntity=Item.class, mappedBy="purchase", fetch =
> FetchType.EAGER, cascade = {CascadeType.ALL})
> public Set<Item> getItems() {
> return items;
> }
>
> In item definition of purchase link
>
> @ManyToOne
> @JoinColumn(name="purchase_id", nullable=false, updatable=true)
> public Purchase getPurchase() {
> return purchase;
> }
>
>
> On Purchase delete will throw exception:
> Cannot delete or update a parent row: a foreign key constraint fails
> (`items/item`, CONSTRAINT `FKCBE86B0CEAAD847A` FOREIGN KEY (`purchase_id`)
> REFERENCES `purchase` (`id`))
>
> Any ideas how to setup cascade delete?
>
> Thanks.
>
--
View this message in context:
http://www.nabble.com/cascade-delete-in-appfuse-2-tf3395430s2369.html#a9453417
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]