我有这个名为:
"SELECT new net.yy.domain.RemoteObject(r.id, r.name)
FROM RemoteObject r LEFT JOIN r.tenant t
WHERE ((upper(r.name) like upper(:name) AND :name IS NOT NULL) OR :name IS NULL)
AND ((upper(t.name) = upper(:tenant) AND :tenant IS NOT NULL) OR :tenant IS NULL)"
我在输入中使用姓名或租户来称呼它。 使用Oracle和mySQL,一切都还可以。 但是对于postgreSQL,部分"或者XX是空的"似乎被忽略了。 我有错误消息:
Caused by: org.postgresql.util.PSQLException: ERROR: function upper(bytea) does not exist
请问您有什么想法吗? HQL请求必须能够与Oracle,Mysql和PostgreSQL一起使用。
java类:
@Id
@Column(name = "ID")
@GeneratedValue(generator = "seq_ro_gen", strategy = GenerationType.SEQUENCE)
@SequenceGenerator(name = "seq_ro_gen", sequenceName = "SEQ_RO", allocationSize = 1, initialValue = 1)
private Long id;
@Basic
@Column(name = "NAME", length = 64, unique = true)
private String name;
@Basic
@Column(name = "LOWERNAME", length = 64, unique = true)
private String lowerName;
@Basic
@Column(name = "PK", columnDefinition = "BLOB")
private byte[] pk;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "TENANTID", referencedColumnName = "ID")
private Tenant tenant;
... Some other fields ...
我用特定的postgresql文件覆盖(只有一些字段):
<entity class="RemoteObject">
<attributes>
<id name="id">
<generated-value strategy="IDENTITY"/>
</id>
<basic name="pk">
<column name="PK" column-definition="text" />
</basic>
<basic name="name">
<column name="NAME" column-definition="varchar" length="64" unique ="true" />
</basic>
<basic name="lowerName">
<column name="LOWERNAME" column-definition="varchar" length="64" unique ="true" />
</basic>
</attributes>
</entity>