vlad wrote:
The JPA annotation does not support this feature, and you should not use HBM2DDL in production. You should use
Flyway or Liquibase instead.
If you're using HBM2DDL during testing and you need this functionality, you can provide an additional script that does:
Code:
CREATE UNIQUE INDEX my_unique_constraint ON my_table (name, from, to) WHERE (pid is null and status = 1);
If this DDL statement is located in a script file called: my_unique_constraint.sql, you can provide it to Hibernate like this:
Code:
<property
name="hibernate.hbm2ddl.import_files"
value="my_unique_constraint.sql" />
I am trying to resolve an issue in my application, which supports autosave(every 10 secs) of a form(only one table no child tables). when there is heavy load on the application hibernate inserting duplicate rows with different ids. Could you give me your view on this. Any inputs on how to fix this issue.
I basically check if the row already exists i update the fields, if its not, then create a new object call saveorupdate(object).
My application is Spring/Hibernate based application,
session factory is org.springframework.orm.hibernate4.LocalSessionFactoryBean
transactionManager is org.springframework.orm.hibernate4.HibernateTransactionManager