Hibernate JPA @RowId Example

@RowId

The @RowId annotation is used to specify the database column used as a ROWID pseudocolumn. For instance, Oracle defines the ROWID pseudocolumn which provides the address of every table row.

According to Oracle documentation, ROWID is the fastest way to access a single row from a table.

Support for ROWID mapping feature of Hibernate.

@RowId

If you annotate a given entity with the @RowId annotation and the underlying database supports fetching a record by ROWID (e.g. Oracle), then Hibernate can use the ROWID pseudo-column for CRUD operations.

Example : @RowId entity mapping

@Entity(name = "Product")
@RowId("ROWID")
public static class Product {

@Id
private Long id;

@Column(name = "`name`")
private String name;

@Column(name = "`number`")
private String number;

//Getters and setters are omitted for brevity

}
Now, when fetching an entity and modifying it, Hibernate uses the ROWID pseudo-column for the UPDATE SQL statement.

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation