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 - JSF JPA CRUD - cannot Destroy product
Summary: JSF JPA CRUD - cannot Destroy product
Status: RESOLVED WONTFIX
Alias: None
Product: javaee
Classification: Unclassified
Component: Samples (show other bugs)
Version: 7.2
Hardware: PC Linux
: P3 normal (vote)
Assignee: Martin Janicek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-17 08:19 UTC by Vladimir Riha
Modified: 2012-10-30 13:02 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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!