I have a dependent map on my persistant class… I was thinking the indexed=”true” would cause DN to add an index to the key and value columns on the generated table, but it seems completely ignored. Of course I can manually add the index.. but is there a way to make DN do it for me either via annotations (preferred) or xml?
@Persistent
@Key(types=String.class,indexed="true",index = "key_idx")
@Value(types=String.class,dependent="true",indexed="true",index = "value_idx")
@Join
private Map<String,String> metadata = new HashMap<>();
in response to DN’s comment it is using mysql… here are the relevant logs I can find and the resulting schema… is there something else I can add to help figure out what I’m doing wrong?:
DataNucleus.Datastore.Schema:58 - Column "account_metadata.id_oid" added to internal representation of table.
DataNucleus.Datastore:58 - Field [com.core.data.account.Account.metadata] -> Column(s) [account_metadata.id_oid] using mapping of type "org.datanucleus.store.mapped.mapping.PersistableMapping" (org.datanucleus.store.rdbms.mapping.IntegerRDBMSMapping)
DataNucleus.Datastore.Schema:58 - Column "account_metadata.`key`" added to internal representation of table.
DataNucleus.Datastore:58 - Field [com.core.data.account.Account.metadata] -> Column(s) [account_metadata.`key`] using mapping of type "org.datanucleus.store.mapped.mapping.StringMapping" (org.datanucleus.store.rdbms.mapping.VarCharRDBMSMapping)
DataNucleus.Datastore.Schema:58 - Column "account_metadata.`value`" added to internal representation of table.
DataNucleus.Datastore:58 - Field [com.core.data.account.Account.metadata] -> Column(s) [account_metadata.`value`] using mapping of type "org.datanucleus.store.mapped.mapping.StringMapping" (org.datanucleus.store.rdbms.mapping.ClobRDBMSMapping)
DataNucleus.Datastore.Schema:58 - Validating 2 index(es) for table account_metadata
DataNucleus.Datastore.Schema:58 - Validating 1 foreign key(s) for table account_metadata
DataNucleus.Datastore.Schema:58 - Validating 1 unique key(s) for table account_metadata
CREATE TABLE `account_metadata` (
`id_oid` int(11) NOT NULL,
`key` varchar(64) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
`value` mediumtext,
PRIMARY KEY (`id_oid`,`key`),
KEY `account_metadata_n49` (`id_oid`),
CONSTRAINT `account_metadata_fk1` FOREIGN KEY (`id_oid`) REFERENCES `account` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SVN trunk of DataNucleus now supports indexes on key/value columns of map join tables where the key/value are non-persistent (previously supported for embedded key/values only).