Skip to content

Instantly share code, notes, and snippets.

@thjanssen
Created May 9, 2017 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thjanssen/854e0d075cc386da43a54b4304ba7c28 to your computer and use it in GitHub Desktop.
Save thjanssen/854e0d075cc386da43a54b4304ba7c28 to your computer and use it in GitHub Desktop.
@Entity
@DynamicUpdate
public class Book {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", updatable = false, nullable = false)
private Long id;
@Version
private int version;
private String title;
private Double price;
...
}
Book b = em.find(Book.class, 1L);
b.setPrice(9.99D);
12:45:23,097 DEBUG [org.hibernate.SQL] -
select
book0_.id as id1_0_0_,
book0_.price as price2_0_0_,
book0_.publishingDate as publishi3_0_0_,
book0_.title as title4_0_0_,
book0_.version as version5_0_0_
from
Book book0_
where
book0_.id=?
12:45:23,133 DEBUG [org.hibernate.SQL] -
update
Book
set
price=?,
version=?
where
id=?
and version=?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment