Coggle requires JavaScript to display documents.
session.createSQLQuery("select id from product") .addSynchronizedEntityClass(Product.class) .uniqueResult())
session.createSQLQuery("select id from product") .setFlushMode(FlushMode.ALWAYS);
entityManager .unwrap(Session.class) .setHibernateFlushMode(FlushMode.ALWAYS);
@Entity(name="products") @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name="product_type", discriminatorType = DiscriminatorType.INTEGER) public class MyProduct { // ... }
@Entity @DiscriminatorValue("1") public class Book extends MyProduct { // ... }
@Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorFormula("case when author is not null then 1 else 2 end") public class MyProduct { ... }
Person person = buildPerson("devender"); Address address = buildAddress(person); person.setAddresses(Arrays.asList(address)); session.persist(person); session.flush(); assertThat(session.contains(person)).isTrue(); assertThat(session.contains(address)).isTrue(); session.detach(person); assertThat(session.contains(person)).isFalse(); assertThat(session.contains(address)).isFalse(); session.unwrap(Session.class) .buildLockRequest(new LockOptions(LockMode.NONE)) .lock(person); assertThat(session.contains(person)).isTrue(); assertThat(session.contains(address)).isTrue();
@NamedQueries({ @NamedQuery(...), ..., @NamedQuery(...) })
@NamedQuery
@Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "book_generator") @SequenceGenerator(name="book_generator", sequenceName = "book_seq", allocationSize=50) @Column(name = "id", updatable = false, nullable = false) private Long id;
@Id @GeneratedValue(strategy = GenerationType.TABLE, generator = "book_generator") @TableGenerator(name="book_generator", table="id_generator", schema="bookstore") @Column(name = "id", updatable = false, nullable = false) private Long id;
public Entity getEntity() { if (entity == null) { entity = loadEntity(); } return entity; }
children.size(); children.iterator();
@Transient private transient DirtyTracker $$_hibernate_tracker; public void $$_hibernate_trackChange(String paramString) { if (this.$$_hibernate_tracker == null) { this.$$_hibernate_tracker = new SimpleFieldTracker(); } this.$$_hibernate_tracker.add(paramString); }
public void setTitle(String title) { this.title = title; } ... becomes public void setTitle(String title) { if(!EqualsHelper.areEqual(this.title, title)) { this.$$_hibernate_trackChange("title"); } this.title = title; }
public void addBook(Book book) { books.add(book); book.authors.add(this); } public void removeBook(Book book) { books.remove(book); book.getAuthors().remove(this); }
@NamedQuery(name = "DeptEmployee_findByEmployeeNumber", query = "from DeptEmployee where employeeNumber = :employeeNo")
FROM Employee emp JOIN FETCH emp.department dep