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 177638 - [68cat] Controllers trying to write a read only relationship
Summary: [68cat] Controllers trying to write a read only relationship
Status: RESOLVED WONTFIX
Alias: None
Product: javaee
Classification: Unclassified
Component: Persistence (show other bugs)
Version: 6.x
Hardware: All All
: P3 normal with 1 vote (vote)
Assignee: Sergey Petrov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-25 15:53 UTC by javydreamercsw
Modified: 2015-09-17 13:09 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Database Script (46.38 KB, application/octet-stream)
2009-11-25 15:56 UTC, javydreamercsw
Details
Modified controller class (6.30 KB, text/plain)
2009-11-25 15:58 UTC, javydreamercsw
Details
JUnit test where the issue manifests (1.76 KB, text/plain)
2009-11-25 16:00 UTC, javydreamercsw
Details
Project source (281.50 KB, application/x-zip-compressed)
2010-02-11 07:07 UTC, javydreamercsw
Details

Note You need to log in before you can comment on or make changes to this bug.
Description javydreamercsw 2009-11-25 15:53:45 UTC
Build 200911241400

I have a class that has a relationship marked as read only with the "insertable = false, updatable = false" modifiers for the joincolumn definition. The controller generated from it tries to update (write) to this relationship when I'm writing an entity causing cyclical behavior.

I had to comment out the related code to make it stop.
Comment 1 javydreamercsw 2009-11-25 15:56:55 UTC
Created attachment 91705 [details]
Database Script

Use this script to create the database then use the wizards to create the entities and then the controlers.
Comment 2 javydreamercsw 2009-11-25 15:58:39 UTC
Created attachment 91707 [details]
Modified controller class

This is the modified class that makes it work. (Change only made in the create method)
Comment 3 javydreamercsw 2009-11-25 16:00:17 UTC
Created attachment 91708 [details]
JUnit test where the issue manifests

I'm using EclipseLink 2.0. Not sure if this has something to do.
Comment 4 Sergey Petrov 2010-02-10 09:25:32 UTC
Unit test use VMUserJpaController for create but modified controller is UserModifiedRecordJpaController, is there the same problem in VMUserJpaController or it's wrong test?
Comment 5 javydreamercsw 2010-02-10 09:51:30 UTC
The problem is in the relationship between the two. Check commented out code in UserModifiedRecordJpaController. Also the work done in the entity listener.
Comment 6 Sergey Petrov 2010-02-11 03:06:45 UTC
According to jpa spec insertable/updatable should be used just to control if this field will be used in INSERT/UPDATE sql command, looks like it's not prohibited to update this locally, but it will not be updated with commit in database and changes may be lost after commit. 
But may be I miss something as can't try test as is. 

What library should be used for DatabaseManager and MD5? I don't see it in eclipselink. Or is DatabaseManager/MD5 usage can be removed or replaced with just string/number and at what step the problem will appear? 

Do you mean UserModifiedRecordJpaController::create is called from some event handler? I don't see this usage if just generate entities and then jpa controllers and use attached unit test.
Comment 7 javydreamercsw 2010-02-11 05:49:41 UTC
DatabaseManager and MD5 are classes defined in my project. VMUser has a persistence listener from which UserModifiedRecord is created. Looks like you need the whole project?
Comment 8 Sergey Petrov 2010-02-11 05:54:11 UTC
full project or part enough to see the issue, 
are you sure it's not because of your listener?
Comment 9 javydreamercsw 2010-02-11 05:57:46 UTC
Is provoked by my listener but it goes like this:

1. An entity is changed/created/deleted so when its going to be stored an UserModified record is created.
2. When the record is created another change is triggered on VMUser (by their relationship)
3. Step 2 causes a loop unless the commented code is removed..
Comment 10 Sergey Petrov 2010-02-11 06:00:44 UTC
yes, it solve the problem, but it may not mean commented code is wrong, it's just one of places to break a loop.
Comment 11 javydreamercsw 2010-02-11 06:07:55 UTC
SO how do I proceed?
Comment 12 Sergey Petrov 2010-02-11 06:23:41 UTC
I need to investigate a bit more.
Also if you can share more from your project so there will be easy way to reproduce a problem from current realization it will be good.
Comment 13 javydreamercsw 2010-02-11 07:07:55 UTC
Created attachment 94083 [details]
Project source

Here is the source. The test will make sense from it.
Comment 14 Sergey Petrov 2010-04-01 09:25:16 UTC
On first attempt have a problem with password reset in persistemce.xml, if I clean&build persitense.xml contain proper code with password set to appropriate value, after test execution password value is reset to "", and eclipselink can't connect to mysql with empty password, it's strange. Tried to create test myself and all works fine without password resetting. Still not sure it's an issue, but need to investigate a bit more.
Comment 15 Martin Balin 2015-09-17 13:09:41 UTC
Report from old NetBeans version. Due to code changes since it was reported likely not reproducible now. Feel free to reopen if happens in 8.0.2 or 8.1.