Oh, so it isn't actually a composite key. I didn't understand
properly then. Well, using a UserType is exactly the right 
approach. You would also need to implement IdentifierGenerator
to generate instances of PrimaryKey (your implementation could 
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="key" type="my.pkg.PrimaryKeyType">
   <generator class="my.pkg.PrimaryKeyGenerator"/>
</id>

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, 10 December 2002 10:16 AM
> To: Gavin King; Chris Winters
> Cc: [EMAIL PROTECTED]
> Subject: RE: [Hibernate] custom identifier class
> 
> 
> hi,
> 
> On Tue, 10 Dec 2002 09:10:09 +1100, "Gavin King" 
> <[EMAIL PROTECTED]>
> 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....
> > 
> > I can't imagine why you would want it....
> 
> i'm trying to port some legacy code over to hibernate. the 
> code relies on a PrimaryKey class for identifying objects. 
> this is not a composite key, so automatic generation totally 
> makes sense (it really just encapsulates a String id 
> property). changing this all over the place would be somewhat 
> painful, that's why i was trying to work around it within the 
> boundaries of Hibernate.
> 
> 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 
> 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)
> 
> thanks,
>     viktor
> -- 
>   
>   [EMAIL PROTECTED]
> 
> -- 
> http://fastmail.fm - Faster than the air-speed velocity of an
>                       unladen european swallow
> 


********** 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 **********



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to