datastax cassandra对象映射器一次只能读取一个实体
datastax cassandra object mapper can only read single entity at a time
关于datastax cassandra对象映射器,阅读manual, it seems that the mapper interface only allow single entity query. I’ll have to provide the whole primary keys for the mapper. In many cases, I need to query the database to get more than one row. For that, I can use the accessor。那我根本不需要对象映射器。
另一种选择是我可以使用准备好的语句。
在我看来,如果我的理解是正确的话,映射器的功能相当有限。如果我只能使用访问器来执行简单和复杂的查询,为什么我还要费心去创建对象映射器(并维护它)?
编辑
我刚刚在另一个问题上遇到 。它表明我们可以使用映射器来映射复杂查询返回的 ResultSet
。这对于删除样板代码很有用,这证实了@Alex Ott 所说的内容。
很多时候你需要根据主键的值读取一个条目,并将其转换为"business"对象。或者您想保存或删除数据。这就是 mapper 让生活更轻松的案例。
关于datastax cassandra对象映射器,阅读manual, it seems that the mapper interface only allow single entity query. I’ll have to provide the whole primary keys for the mapper. In many cases, I need to query the database to get more than one row. For that, I can use the accessor。那我根本不需要对象映射器。
另一种选择是我可以使用准备好的语句。
在我看来,如果我的理解是正确的话,映射器的功能相当有限。如果我只能使用访问器来执行简单和复杂的查询,为什么我还要费心去创建对象映射器(并维护它)?
编辑
我刚刚在另一个问题上遇到 ResultSet
。这对于删除样板代码很有用,这证实了@Alex Ott 所说的内容。
很多时候你需要根据主键的值读取一个条目,并将其转换为"business"对象。或者您想保存或删除数据。这就是 mapper 让生活更轻松的案例。