47 lines
3.3 KiB
Plaintext
47 lines
3.3 KiB
Plaintext
Hibernate: create global temporary table HTE_book(rn_ integer not null, id bigint, version bigint, author varchar(255), title varchar(255), primary key (rn_)) transactional
|
|
Hibernate: create global temporary table HTE_widget_sequence(rn_ integer not null, id bigint, name varchar(255), primary key (rn_)) transactional
|
|
Hibernate: create table book (id bigint not null, author varchar(255), title varchar(255), version bigint not null, primary key (id))
|
|
Hibernate: create table widget_identity (id bigint generated by default as identity, name varchar(255), primary key (id))
|
|
Hibernate: create table widget_sequence (id bigint not null, name varchar(255), primary key (id))
|
|
Hibernate: create sequence book_seq start with 1 increment by 50
|
|
Hibernate: create sequence widget_seq start with 1 increment by 25
|
|
Hibernate: select next value for book_seq
|
|
Hibernate: /* insert for com.ankurm.hibernatedemo.model.Book */insert into book (author,title,version,id) values (?,?,?,?)
|
|
binding parameter (1:VARCHAR) <- [Joshua Bloch]
|
|
binding parameter (2:VARCHAR) <- [Effective Java]
|
|
binding parameter (3:BIGINT) <- [0]
|
|
binding parameter (4:BIGINT) <- [1]
|
|
SEED: inserted Book id=1
|
|
--- Step 1: session.get() on an existing id ---
|
|
about to call session.get(Book.class, 1)
|
|
Hibernate: select b1_0.id,b1_0.author,b1_0.title,b1_0.version from book b1_0 where b1_0.id=?
|
|
binding parameter (1:BIGINT) <- [1]
|
|
get() returned: Book{id=1, title=Effective Java, author=Joshua Bloch, version=0}
|
|
--- Step 2: session.get() on a missing id ---
|
|
about to call session.get(Book.class, 999001)
|
|
Hibernate: select b1_0.id,b1_0.author,b1_0.title,b1_0.version from book b1_0 where b1_0.id=?
|
|
binding parameter (1:BIGINT) <- [999001]
|
|
get() returned: null (no exception thrown)
|
|
--- Step 3: session.getReference() on an existing id ---
|
|
getReference() returned proxy of class com.ankurm.hibernatedemo.model.Book$HibernateProxy -- no SELECT above this line
|
|
now calling proxy.getTitle() ...
|
|
Hibernate: select b1_0.id,b1_0.author,b1_0.title,b1_0.version from book b1_0 where b1_0.id=?
|
|
binding parameter (1:BIGINT) <- [1]
|
|
getTitle() returned 'Effective Java' -- the SELECT for this ran just above this line
|
|
--- Step 4: session.getReference() on a missing id ---
|
|
getReference() returned a proxy for a row that does not exist -- no exception yet: com.ankurm.hibernatedemo.model.Book$HibernateProxy
|
|
Hibernate: select b1_0.id,b1_0.author,b1_0.title,b1_0.version from book b1_0 where b1_0.id=?
|
|
binding parameter (1:BIGINT) <- [999001]
|
|
accessing the proxy threw jakarta.persistence.EntityNotFoundException: No row with the given identifier exists for entity [com.ankurm.hibernatedemo.model.Book with id '999001']
|
|
--- Step 5: proxy accessed after its session is closed ---
|
|
session closed. proxy in hand: com.ankurm.hibernatedemo.model.Book$HibernateProxy
|
|
accessing the proxy after close threw org.hibernate.LazyInitializationException: Could not initialize proxy [com.ankurm.hibernatedemo.model.Book#1] - no session
|
|
--- Step 6: proxy identity vs a real loaded instance ---
|
|
Hibernate: select b1_0.id,b1_0.author,b1_0.title,b1_0.version from book b1_0 where b1_0.id=?
|
|
binding parameter (1:BIGINT) <- [1]
|
|
real.getClass() = com.ankurm.hibernatedemo.model.Book
|
|
proxy.getClass() = com.ankurm.hibernatedemo.model.Book$HibernateProxy
|
|
proxy instanceof Book.class: true
|
|
real.getClass() == proxy.getClass(): false
|
|
real.equals(proxy) before proxy access: false
|