我试图在postgresql表中获得行的大小,我发现pg_column_size可以做到这一点,但它不适用于hibernate:
@Query("SELECT pg_column_size(t.*) as filesize FROM TABLE as t where name=:name")
int getSize(@Param("name") String name);
intellij给出了这个错误:
< operator >或预期的got '('‘)
我猜问题在于hibernate不支持特定的postgresql查询,它只支
我编写了要更新的查询,但其中出现了错误。
@Modifying
@Transactional
@Query(value = "UPDATE lat_lang SET geom=ST_transform(ST_SetSRID(ST_MakePoint(:lat,:lang),4326),3857),latitude=:lat,longitude=:lang WHERE uid=1;", nativeQuery = true)
int updateGeom(@Param("lat") Double lat, @Param("lang") Doubl
我使用Hibernate和JpaRepository来处理我的DB操作。
我有这个查询(为了简化,因为原始查询相当大):
@Query(value="select * from history h where h.project_id in :projects", nativeQuery=true)
List<History> getHistoriesByProjectsIn(@Param("projects")List<Long> projects);
当我传递有效而不是空的List<Long>时,它就起作用了。然而,当我传
我正在使用JPA/Hibernate。所以我想在JPQL中做nullCheck,但是当我这样做时,它并不决定dataType。
JPQL查询:
@Query("select a from Attribute a where :attributeId is null OR a.id = :attributeId")
Page<Attribute> findByAttributeId(@Param("attributeId") UUUID attributeId);
例外情况:
错误:无法确定参数$1在org.postgresql.core.v3
我一直在谷歌上寻找一个简单的解决方案,让我们的新postgresql + hibernate设置可以使用不区分大小写的搜索,但没有运气。我们之前一直在使用mysql,它有一个关于大小写无感觉搜索的策略,然而Postgresql似乎缺乏这一点。
例如,我希望Hibernate/Postgresql为以下各项返回相同的结果:
SELECT * FROM Foo where bar = 'Hello World';
和
SELECT * FROM Foo where bar = 'hello wOrlD';
我找到的唯一解决方案是以某种方式将一个'ilike‘
我正在使用PostgreSQL和JPA/Hibernate。我需要构建一个包含PostgreSQL regex比较运算符(name ~ 'pattern')的HQL查询。我有以下方言:
public class PostgreSQLExtendedDialect extends PostgreSQL95Dialect {
public PostgreSQLExtendedDialect() {
registerFunction("regexp_matches", new SQLFunctionTemplate(BooleanType.I
我试图像这样查询postgresql:
SELECT id , run_time
FROM run WHERE run.run_time > '2020-02-04' and run.run_time::date <= '2020-02-05'
我的问题是run.run_time::date
:当我在调试中打印查询时,查询显示:
SELECT id , run_time
FROM run WHERE run.run_time > '2020-02-04' and run.run_time::date &l
我想为包含一些DB的hibernate中的XML内容的列支持where子句。我在Oracle中通过扩展org.hibernate.dialect.OraclexDialect类和通过registerFunction方法注册registerFunction函数来实现这一点。生成的查询示例:
SELECT *
FROM OM_PERSON this_
WHERE xmltype.createxml(this_.config_xml).existsNode('/*[condition/text()="19943"]')=1;
在hibernate (用于Oracle)
我正在尝试使用以下查询查询底层数据库的复制状态:
em.createNativeQuery("SELECT application_name, backend_start, state, cast(write_lag as text) FROM pg_stat_replication;").getResultList();
不幸的是,除了application_name之外的所有列都返回null。即使我只跑
em.createNativeQuery("SELECT backend_start FROM pg_stat_replication;").getRes
环境:
hibernate-实体管理器:4.3.6.Final
PostgreSQL 9.3.5
我执行当前的JPQL查询
select distinct entity
from Incidence entity
left join treat(entity.road as Road) as road
where entity.road is not null and lower(road.nomenclature) like :value
查看日志文件,这将为PostgreSQL生成以下查询:
select
distinct
....
....
from public
我正在使用@DataJpaTest来测试我的存储库。
@Query(
"SELECT AVG(a.rating) as averageValue a.id as someId FROM SomeTable as a where someTable.id = :id")
SomReturnObject getExampleTable(@Param(value = "id") String dcsPoolIdPram);
在没有group by的情况下,查询不应该工作,但是即使它失败了,它也不能工作。我正在使用H2内存数据库.当我使用Postgres数据库运
当使用PostgreSQL将数据存储在类似字符串的已验证类型的字段(如xml、json、jsonb、xml、ltree等)中时,INSERT或UPDATE会失败,错误如下:
column "the_col" is of type json but expression is of type character varying
..。或
column "the_col" is of type json but expression is of type text
为什么?我能做些什么?
我正在使用JDBC (PgJDBC)。
这种情况通过Hibernate、JPA
我的应用程序使用spring v2.6.1和Postgres。下面的方法在我的一个存储库中。
@Query(value = "SELECT * from subscriptions s " +
"WHERE (:merchantID is NULL OR s.created_by = cast(:merchantID AS text)) " +
"AND (:status is NULL or s.status IN (:status))", nativeQuery = true)
List