Skip to content
Advertisement

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 jdbc batching and enable flushing through hibernate means. Add

How does Hibernate do row version check for Optimistic Locking before committing the transaction

When before committing the current transaction hibernate checks the version of the row, it should issue an sql select statement for fetching ithe row. Assume that after issuing that select statement hibernate finds out that the row version is not changed, hence it should proceed with committing the transaction. I’m wondering how hibernate can be sure that in time slot

Hibernate not allowing to increment by 5 in sequence

I have following db sequence Java However with Hibernate I am getting following error which says hibernate is expecting increment by 50. Why is so? Edit1 Added java code. Answer The error message is quite clear. You have enabled (or not disabled) schema validation, so when the application starts Hibernate is comparing the database with what it expects from annotations

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 following API is available to implementors I use the

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(columnDefinition = “Geometry”) private Point location; creation of data; SampleEntity se = new SampleEntity(); se.setName(“Sample1”); se.setAge(30); GeometryFactory gf = new GeometryFactory(new PrecisionModel(), 4326); Point location1

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 EXISTS clause.

Advertisement