Skip to content

Tag: hibernate

How to log failed sql in hibernate?

I’m building a SpringBoot application with spring-data-jpa. I know how to log all sqls from this question. How to print a query string with parameter values when using Hibernate But what if I only want to log failed sqls? Answer There are two options: Configure sql logging with parameter values. Disable…

Release of a SELECT… FOR UPDATE lock

My question is very simple: what is the inverse SQL statement for SELECT ID FROM TABLE FOR UPDATE NOWAIT? How do I release a lock during the same transaction that acquired it before committing? Expanding: I am writing portable API code that leverages Hibernate to apply row-level locks to entities. The followi…

MSSql server jpa spatial exception

Is it possible to use sql spatial data in jpa? I ve MS SQL Server 2014 Express Edition. I m trying to use spatial data as follows; maven (pom.xml) dependencies; db dialect; spring.jpa.hibernate.dialect=org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect entity definition; @Column(columnDefinit…

insert if not exists in HQL

I am trying to write a query in HQL which can insert a record if it does not exists (with same name) so that there is no duplicate insertion when done from multiple threads. However, the record is not inserted. I suspect this is because the table is empty and the subquery returns 0 records despite the NOT EXI…