This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 220249

Summary: JSF JPA CRUD - cannot Destroy product
Product: javaee Reporter: Vladimir Riha <vriha>
Component: SamplesAssignee: Martin Janicek <mjanicek>
Status: RESOLVED WONTFIX    
Severity: normal CC: vriha
Priority: P3    
Version: 7.2   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:

Description Vladimir Riha 2012-10-17 08:19:43 UTC
To reproduce:
- 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)
Comment 1 Martin Janicek 2012-10-29 15:19:35 UTC
Gosh, I don't believe this ever worked :( ..I'll take a look at it.. Thanks vlado
Comment 2 Martin Janicek 2012-10-30 12:44:58 UTC
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?
Comment 3 Vladimir Riha 2012-10-30 12:55:59 UTC
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.
Comment 4 Martin Janicek 2012-10-30 13:02:54 UTC
(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!