- go to [JsfJpaCrud]/faces/pages/productCode/List.jsp
- click on Destroy in some table row
=> result is
This Product (986420) cannot be destroyed since the PurchaseOrder jpa.entities.PurchaseOrder[orderNum=10398009] in its purchaseOrderCollection field has a non-nullable productId field.
Product Version: NetBeans IDE 7.2.1 (Build 201210100934)
Java: 1.7.0_10-ea; Java HotSpot(TM) Client VM 23.6-b04
System: Linux version 3.2.0-31-generic-pae running on i386; UTF-8; en_US (nb)
Gosh, I don't believe this ever worked :( ..I'll take a look at it.. Thanks vlado
In the end, I'm not sure if this is really an issue. Just the exception is a little bit confusing for someone not familiar with Java EE applications.
The problem is that the ProductCode entity has JPA/Hibernate mapping @OneToMany to the Product entity. It does not make much sense (from the domain logic point of view) to enable deleting ProductCode if it has at least one relation to some Product (it would either make Product table inconsistent because Products wouldn't had any ProductCode or we would have to delete all related Products - which doesn't sound like a correct solution with respect to the domain model).
I can somehow try to handle and change the exceptions coming from JPA/Hibernate, but I'm not sure if it's worth for the work.
I would rather close this as WONTFIX (it was always like this and I believe that Java EE developers understand what's going on there). What do you think Vlado?
I'm sorry, this is my bad as I didn't realize this basic dependency and didn't get the message :/ I absolutely agree with wontfix, thanks for evaluation.
(In reply to comment #3)
> I'm sorry, this is my bad as I didn't realize this basic dependency and didn't
> get the message :/ I absolutely agree with wontfix, thanks for evaluation.
No worries. Thanks for a quick response!