Have you looked at the Hibernate @SQLInsert Annotation?
@Entity
@Table(name="story_count")
@SQLInsert(sql="INSERT INTO story_count(id, view_count) VALUES (?, ?)
ON DUPLICATE KEY UPDATE view_count = view_count + 1" )
public class StoryCount
More Related Contents:
- Enum in Hibernate, persisting as an enum
- JPA JoinColumn vs mappedBy
- Hibernate Annotations – Which is better, field or property access?
- What’s the difference between JPA and Hibernate? [closed]
- What is the solution for the N+1 issue in JPA and Hibernate?
- Hibernate 5 :- org.hibernate.MappingException: Unknown entity
- Bypass GeneratedValue in Hibernate (merge data not in db?)
- How should equals and hashcode be implemented when using JPA and Hibernate
- Using Hibernate’s ScrollableResults to slowly read 90 million records
- The server time zone value ‘AEST’ is unrecognized or represents more than one time zone
- Hibernate – @ElementCollection – Strange delete/insert behavior
- session.connection() deprecated on Hibernate?
- Automatic reserved word escaping for Hibernate tables and columns
- Location of hibernate.cfg.xml in project?
- What’s the use of session.flush() in Hibernate
- @GeneratedValue polymorphic abstract superclass over MySQL
- Spring, Hibernate, Blob lazy loading
- How can I use MySQL assign operator(:=) in hibernate native query?
- JPA: Implementing Model Hierarchy – @MappedSuperclass vs. @Inheritance
- Hibernate Criteria Query to get specific columns
- com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed
- Hibernate sequence on oracle, @GeneratedValue(strategy = GenerationType.AUTO)
- Specifying an Index (Non-Unique Key) Using JPA
- Hibernate: Create Mysql InnoDB tables instead of MyISAM
- How does Hibernate detect dirty state of an entity object?
- Hibernate throws strange error: Class is not mapped
- HibernateException: Couldn’t obtain transaction-synchronized Session for current thread
- Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
- Hibernate @PostLoad never gets invoked
- HQL recursion, how do I do this?