Paul Mossman wrote: > Hi all, > > For XX-7131 my plan is to migrate (upon upgrade) the 4.0 > 'alarm_contacts' table entries into the 4.2 'alarm_group_emailcontacts' > table. > > The challenge is generating the 'index' value for the > 'alarm_group_emailcontacts' table entries. It seems like there should > be a sequence for this table, but there isn't.
That's because it's an index not the ID. And 'email contact' is defined as 'component' not as an 'entity'. (Please read Hibernate docs on components vs. entities). 'index' field is used to determine the order in the table. Quite frankly I am not sure if order even matters here - we could have probably mapped it as a 'bag' as not as a 'list' which would let us to drop index column altogether. > > This table has a composite primary key, both 'index' and > 'alarm_group_id', which surely has something to do with why it doesn't > have a sequence. Yes. > > Looking in alarm.hbm.xml, the 'alarm_group' table is used by the > AlarmGroup class (and it has a sequence.) AlarmGroup has an > "emailAddresses" member list, which uses the > 'alarm_group_emailcontacts'. > >>From experimentation, it looks like Hibernate is smart enough to > re-write the 'index' values in 'alarm_group_emailcontacts' when it saves > an AlarmGroup. > > So when inserting entries upon upgrade, I think it would be OK to simply > ensure the 'index' values start at 0 and increment by 1. i.e. There is > no need to update a sequence. Yes. When you inserting new data from SQL you'll need to use sequence for 'alarm_group_id' but you can generate you 'index' as long as it starts with 0 and is consecutive. [...] BTW: I missed that when taking this patch but whenever possible table names should be 'singular'. As is 'alarm_group_emailcontact' not 'alarm_group_emailcontacts'. D. _______________________________________________ sipx-dev mailing list [email protected] List Archive: http://list.sipfoundry.org/archive/sipx-dev Unsubscribe: http://list.sipfoundry.org/mailman/listinfo/sipx-dev sipXecs IP PBX -- http://www.sipfoundry.org/
