This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Okay. I have a weird question I was wondering if someone can help me out with. I have a method that's job is basically to return the entire table. It works, but returns the same row twice. Is there something I'm doing wrong with the iterator?
So... any ideas why I'm getting twice as many rows? Do you need to see any more code then I've displayed?
Casey Kcins
Greenhorn
Joined: Mar 12, 2007
Posts: 16
posted
0
Okay, well that's really weird. The Database name is Appointment
I have an Appointment class, and a DoctorsAppointment class (which extends Appointment).
When I set up my query (from Appointment), for some reason, it grabbed it for both Appointment, and DoctorsAppointment. Which doubled the result.
When I queried (from DoctorsAppointment), which is not the name of the table, I got the correct result set.
When you declare inheritance mapping, the type of mapping you do will change the type of query that is run, if you use <union-subclass> (table per implemented subclass) the query will unionize the subclass tables into one result set, which might cause your duplicate rows. a <joined-subclass> (third normal form data tables) will do a join between the parent and child tables, which might be more of what you are looking for, and finally <subclass> is for a single table.
What do your tables look like, and how did you map them?
When I set it up in the application, I only called the subclass (DoctorsAppointment). There isn't a use for the main class really.
There won't be any subclasses to the main class (Appointment), so I don't think I'll need to do that mapping.
I'm confused, you made a Appointment class then subclassed it with DoctorsAppointment, but you don't ever expect to need to subclass Appointment ever again, no DentistsAppointment, or AccountantAppointment?
If that is the case, my question is why have that Appointment superclass?
Mark Good to know though.
Casey Kcins
Greenhorn
Joined: Mar 12, 2007
Posts: 16
posted
0
If that is the case, my question is why have that Appointment superclass?
Neurosis?
No. It bothered me that since I was making a many-to-one relationship with the doctor class, I needed to reference Doctor in Appointment. But... It may not necisarrily be a 'doctors appointment'. Even though there may never be another subclass, it just felt right creating one to reference the Doctor class.