Hi,You might be interested to know that other ORM solutions including JDO and Java Persistence allow mapping relational tables to java.util.Map.
Generally there are two patterns. One uses a field of the target class for the key and uses the object reference as the value. Or uses the object reference as the key and a field as a value. Given that objects might not be fully instantiated, this might be a good access pattern (e.g. you might have only the key of an object so you have the key for the lookup in the database). Having a Map can help with scaling to very large relationships, as the relationships can be lazily loaded.
The other pattern is to use a join table that contains a foreign key to the referenced table, a foreign key to the source table, and a column with "extra" information. The extra information can be encoded into a key or value of the Map.Entry on either or both sides.
Regards, Craig On Jan 16, 2007, at 12:26 AM, Peter Schröder wrote:
hi robert, what do you need a name for?you get cayenne-objects from that relationship whom you can access via getters and setters?!-----Ursprüngliche Nachricht----- Von: Robert Zeigler [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 16. Januar 2007 05:14 An: [email protected] Betreff: "map" properties? Currently (to the best of my knowledge), cayenne always represents a to-many relationship as a java.util.List. However, I was thinking it would be nifty if cayenne supported map-representations of to-many relationships. For instance, you could model a relationship between Users and UserPreferences as a map, and specify the "name" property of the UserPreferences table as the map key. Does that make sense? Am Ithe only one who thinks that would be incredibly useful? :) Is somethinglike this already planned for 3.0? If other people would find it useful, then I'd be happy to submit a feature request and also work up a patch. Robert
Craig Russell Architect, Sun Java Enterprise System http://java.sun.com/products/jdo 408 276-5638 mailto:[EMAIL PROTECTED] P.S. A good JDO? O, Gasp!
smime.p7s
Description: S/MIME cryptographic signature
