kotlin:批注中的数组存在一些问题 [英] kotlin: some problems with arrays in annotations

查看:159
本文介绍了kotlin:批注中的数组存在一些问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在批注中遇到了一些问题:

I have a some problem in annotations:

Entity Table(uniqueConstraints = array(UniqueConstraint(columnNames = array("key", "userid")))) 
public class ...

在这种情况下,出现以下错误:

In this case I get the following error:

类型推断失败.预期的类型不匹配:找到: kotlin.Array必需:kotlin.String

Type inference failed. Expected type mismatch: found: kotlin.Array required: kotlin.String

uniqueConstraints = array(...)没有问题,但是Idea向我显示了 columnNames = array(...)

There is no problems with uniqueConstraints = array(...) but Idea shows me error in columnNames = array(...)

我使用 hibernate-jpa-2.1-api-1.0.0.Final.jar

解决方法:取而代之的是我使用复合键(@ javax.persistence.IdClass)

Workaround: Instead uniqueConstraints I using composite key (@javax.persistence.IdClass)

推荐答案

使用传播运算符:

UniqueConstraint(columnNames = *array("key", "userid"))

这篇关于kotlin:批注中的数组存在一些问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆