Right. They have no persistent identity. Therefore, if you want to use an embedded PersistenceCapable as a key, you need to identify one of the embedded fields as a key for the purpose of the map. The alternative is to simply disallow using an embedded PersistenceCapable as a key in a map if the class is defined as datastore identity. But this seems pretty arbitrary.

The only requirements for using objects in a Map in Java are that they implement hashCode and equals properly. How do you go from that contract to "needs a primary key in the database map table"?

Reply via email to