I'm trying to create a mapping file for FAULT_RECORD. Any FAULT_RECORD links to an ERROR_TEXT(wich primary key consists of device_group and errorcode), and to be able to connect them I have to go through DEVICE in order to get the device_group.
I have been searching on various forums but havn't been able to find a similar example, partly because I'm not sure what(keywords) to search for.
If anyone could come up with a solution, or at least point me in the right direction I'd be VERY happy
Of course Sorry.. I've updated the picture/diagram in my first post.
/Andreas
Scott Johnson
Ranch Hand
Joined: Aug 24, 2005
Posts: 518
posted
0
Andreas,
Is the cardinality between device and fault_record really 1 to many?
Both tables have the same primary key, do they not?
The easiest way to map this might be to ignore the relationship between fault_record and error_text. To get the error_text, get the device entity from the fault_record and then retrieve the error_text from the device. To limit the error_text to the desired entity, use a filter. (See Hibernate Reference Sec 10.4.2.)
Scott [ July 16, 2006: Message edited by: Scott Johnson ]
Andreas Jonsson
Greenhorn
Joined: Jul 15, 2006
Posts: 4
posted
0
Originally posted by Scott Johnson: Andreas,
Is the cardinality between device and fault_record really 1 to many?
Both tables have the same primary key, do they not?
The easiest way to map this might be to ignore the relationship between fault_record and error_text. To get the error_text, get the device entity from the fault_record and then retrieve the error_text from the device. To limit the error_text to the desired entity, use a filter. (See Hibernate Reference Sec 10.4.2.)
Scott
[ July 16, 2006: Message edited by: Scott Johnson ]
Hi, and thank you for your reply! Yes it is a one-to-many relationship between DEVICE and FAULT_RECORD. They don't have the same primary key. The DEVICE primary key exists in FAULT_RECORD only as a foreign key.
A FAULT_RECORD needs to be connected to ERROR_TEXT to get the text belonging to a fault. Both ERROR_TEXT and DEVICE are static tables( correct term? ) only used to retrieve the text for a fault.
The problem is that a FAULT_RECORD knows what DEVICE who triggered the fault, but ERROR_TEXTs is only concerned about device_group, and FAULT_RECORD knows nothing about device_groups.
I will now check out the filters you mentioned. Thanks again!
/Andreas [ July 17, 2006: Message edited by: Andreas Jonsson ]
Scott Johnson
Ranch Hand
Joined: Aug 24, 2005
Posts: 518
posted
0
They don't have the same primary key.
Ok, I was thinking that fault_record.id was the same as device.id, which I see now that it's not...
Andreas Jonsson
Greenhorn
Joined: Jul 15, 2006
Posts: 4
posted
0
Originally posted by Scott Johnson: Andreas,
To limit the error_text to the desired entity, use a filter. (See Hibernate Reference Sec 10.4.2.)
Scott
[ July 16, 2006: Message edited by: Scott Johnson ]
Hi again. I've read some about filters now and I'm not so sure it is what I'm looking for when it comes to this mapping thing, but I have already found other places I can use it