我的持久化类有一个依赖映射...我认为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 ...这里是我能找到的相关日志以及由此产生的模式...还有什么我可以添加来帮助弄清楚我做错了什么?:< / p>
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
答案 0 :(得分:1)
DataNucleus的SVN中继现在支持映射连接表的键/值列的索引,其中键/值是非持久的(以前仅支持嵌入式键/值)。