From: Gavin K. <Gav...@ex...> - 2002-12-09 23:34:49
|
Oh, so it isn't actually a composite key. I didn't understand properly then. Well, using a UserType is exactly the right=20 approach. You would also need to implement IdentifierGenerator to generate instances of PrimaryKey (your implementation could=20 just wrap up a built-in key generation strategy). This should work out perfectly - if you have any more problems let me know. The mapping would be: <id name=3D"key" type=3D"my.pkg.PrimaryKeyType"> <generator class=3D"my.pkg.PrimaryKeyGenerator"/> </id> > -----Original Message----- > From: phr...@im... [mailto:phr...@im...]=20 > Sent: Tuesday, 10 December 2002 10:16 AM > To: Gavin King; Chris Winters > Cc: hib...@li... > Subject: RE: [Hibernate] custom identifier class >=20 >=20 > hi, >=20 > On Tue, 10 Dec 2002 09:10:09 +1100, "Gavin King"=20 > <Gav...@ex...> > said: > > This has been requested once before, and it would be very > > trivial to add support for a <generator> subelement of > > <composite-id>. But theres always something very fishy > > about using a generated (ie. synthetic) composite id. It > > really makes no sense. It never even makes sense to have a > > single <key-property> be generated.... > >=20 > > I can't imagine why you would want it.... >=20 > i'm trying to port some legacy code over to hibernate. the=20 > code relies on a PrimaryKey class for identifying objects.=20 > this is not a composite key, so automatic generation totally=20 > makes sense (it really just encapsulates a String id=20 > property). changing this all over the place would be somewhat=20 > painful, that's why i was trying to work around it within the=20 > boundaries of Hibernate. >=20 > i would like to know what sort of direction would you recommend, eg > - replace the PrimaryKey class with String everywhere (-> pain) > - extend hibernate along the lines you mentioned (sounds=20 > good to me, but i need further directions) > - can i just directly use the guts of hibernate to get a new ID? > - map it some other way (i tried a UserType, didn't really work out) >=20 > thanks, > viktor > --=20 > =20 > phr...@im... >=20 > --=20 > http://fastmail.fm - Faster than the air-speed velocity of an > unladen european swallow >=20 ********** CAUTION - Disclaimer ********** This message may contain privileged and confidential information. If you are not the intended recipient of this message (or responsible for delivery of the message to such person) you are hereby notified that any use, dissemination, distribution or reproduction of this message is prohibited. If you have received this message in error, you should destroy it and kindly notify the sender by reply e-mail. Please advise immediately if you or your employer do not consent to Internet e-mail for messages of this kind. Opinions, conclusions and other information in this message that do not relate to the official business of Expert Information Services Pty Ltd ("The Company") shall be understood as neither given nor endorsed by it. The Company advises that this e-mail and any attached files should be scanned to detect viruses. The Company accepts no liability for loss or damage (whether caused by negligence or not) resulting from the use of any attached files. **EIS******** End of Disclaimer ********** |