Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link

Gokcen Guner

Greenhorn
+ Follow
since May 23, 2009
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Gokcen Guner

Although nobody replied, I solved it.
I changed @ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE }) to @ManyToMany(cascade = { CascadeType.ALL })

I have 3 entities user, patient and doctor. Every doctor or patient is a user. I don't use inheritance strategy because I couldn't get an answer from my question here: Previous Problem

Now I'm trying to achieve a similar point without inheritance. Schema is like that:
User <--- OneToOne --> Doctor
User <--- OneToOne --> Patient
Patient <--- ManyToMany --> Doctor

My entities:
User.java:


Patient.java:


Doctor.java:


I've written junit tests for these entities. The doctor methods are working but patients' not.
This one creates 3 users(2 for patients 1 for doctor), 2 patients and a doctor.
DoctorTest.java:


But that one doesn't work as I expect:

PatientTest.java:


The for loop inside testCreatePatient executes up to unitNumber. When i becomes unitNumber + 1 (I mean 21), I'm getting detached entity passed to persist: tr.com.stigma.db.entity.User. It creates 20 doctors, 20 patients and 40 users until i gets to 20. At the 21st insert, I try to add a new patient to an existing doctor, consequently to an existing user. How can I do this?

Stack trace is here:
Although I'm using javax.persistence.CascadeType.ALL, org.hibernate.annotations.CascadeType.ALL, and OnDeleteAction.CASCADE I couldn't manage to delete parent row.
My code is like that:


I have one base class Person and 2 inherited classes Doctor and Patient. One doctor can have one or more patients but a patient is related to only one doctor. That is so simple. But for hours I couldn't delete a doctor that have patients referencing on it. I want the patients to be deleted when their doctor is deleted.
The exception trace is:


What I need to do? I'm using all deletion cascades, orphan removal etc.
Please tell me the problem. It must work, isn't it?


UPDATE:

I've looked at the generated schema:


with the mapping for these annotation configuration:


As you see hibernate is aware of foreign keys PERSON_USER_FK and PATIENT_DOCTOR_FK but doesn't generate Cascade statements. I will go mad please help me.
I have a project due to tomorrow. I'm following the tutorial about custom desktop app with netbeans. I couldnt find any answer anywhere. I think you are the guys that i should ask that.

I created a new detail table that is binded to master table also. its content changes according to selected row in the master table. I added a button to add a new entry to this new detail table. I followed the propertychange support steps in the tutorial same as the original detail table. But it doesnt work.
The exception is here:


The reason of the error is null value returned by getTrialConfirmed() method.

The action performed when button pressed is that:



As you can see the code is same as the one in the tutorial.
The frame opens and I add the data but when refreshed it is gone.

Where is my fault?
Thanks...
12 years ago
I have two JTables in a form. Ive created it with palette function of NetBeans 6.5. I've binded them to database tables. These 2 database tables are connected with foreign keys.
TableA has a foreign key that is primary key of TableB.
My problem is that:
I couldnt construct the master/detail relation between them. For exapmle I want to see related rows in detail table when I select a row in master one. How can I do that?
12 years ago
I have two JTables in a form. Ive created it with palette function of NetBeans 6.5. I've binded them to database tables. These 2 database tables are connected with foreign keys.
TableA has a foreign key that is primary key of TableB.
My problem is that:
I couldnt construct the master/detail relation between them. For exapmle I want to see related rows in detail table when I select a row in master one. How can I do that?

Please delete this thread. I should have posted it to GUI forum...
thanks for reply. Eventually Ive found why the data didnt go to database from JForm.
Im working on a project similar to custom database app tutorial of NetBeans (http://www.netbeans.org/kb/docs/java/gui-db-custom.html)

When I try to add new record to detail table i get he error:



There are a lot of errors too, but that may be enough. If not i can post it too.
I've just followed the instructions in the tutorial to trace the problem and they are all the same. I couldn't find the problem.