我的持久类上有一个依赖映射...我在想 indexed="true" 会导致 DN 为生成的表上的键和值列添加索引,但它似乎完全被忽略了。当然我可以手动添加索引..但是有没有办法让DN通过注释(首选)或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<>();
作为对 DN 评论的回应,它正在使用 mysql……这是我可以找到的相关日志和生成的架构……还有什么我可以添加的东西来帮助找出我做错了什么吗?:
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