2017-05-14 23 views
1

我正在使用Cassandra Phantom驱动程序与Scala和Cassandra构建应用程序。我的代码如下所示:Cassandra Phantom - 无法找到参数助手的隐含值:com.outworkers.phantom.macros.TableHelper [Users,User]

case class User(id: UUID, name:String) 

abstract class Users extends CassandraTable[Users, User] with RootConnector { 
    object id extends UUIDColumn(this) with PartitionKey 
    object name extends StringColumn(this) 

    def save(user: User): Future[ResultSet] = { 
    insert 
     .value(_.id, user.id) 
     .value(_.name, user.name) 
     .consistencyLevel_=(ConsistencyLevel.ALL) 
     .future() 
    } 

    def getById(id: UUID): Future[Option[User]] = { 
    select.where(_.id eqs id).one() 
    } 
} 

但是当我尝试编译代码时它给了我以下错误:

could not find implicit value for parameter helper: com.outworkers.phantom.macros.TableHelper[Users, User] 

我不能够理解为什么这个错误是,当我下面的文件发生。

幻影版本:2.7.6

斯卡拉:2.11.2

回答

1
case class User(id: UUID, name:String) 

abstract class Users extends Table[Users, User] with RootConnector { 
    object id extends UUIDColumn(this) with PartitionKey 
    object name extends StringColumn(this) 

    def save(user: User): Future[ResultSet] = { 
    store(user) 
     .consistencyLevel_=(ConsistencyLevel.ALL) 
     .future() 
    } 

    def getById(id: UUID): Future[Option[User]] = { 
    select.where(_.id eqs id).one() 
    } 
} 

我刚才编译这跟2.7.6,你也不需要手动执行的insert,因为它是为您生成。

+0

你是对的!其实它是'insert()'这是创建错误。用store()代替它,它就起作用了。感谢您的回应:) – himanshuIIITian

相关问题