Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01EQNA6DJ9VgCtW6zhCE8Xud
45 lines
1.0 KiB
Java
Executable File
45 lines
1.0 KiB
Java
Executable File
package com.ankurm.hibernatedemo.proxy;
|
|
|
|
import jakarta.persistence.Entity;
|
|
import jakarta.persistence.FetchType;
|
|
import jakarta.persistence.GeneratedValue;
|
|
import jakarta.persistence.GenerationType;
|
|
import jakarta.persistence.Id;
|
|
import jakarta.persistence.JoinColumn;
|
|
import jakarta.persistence.ManyToOne;
|
|
|
|
/**
|
|
* Child side of {@link ProxyBook#reviews}. See {@link ProxyBook} for why this association
|
|
* exists and how the entity-graph demo in docs/11-proxies-and-lazy-initialization.md uses it.
|
|
*/
|
|
@Entity
|
|
public class ProxyReview {
|
|
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
private Long id;
|
|
|
|
private String comment;
|
|
|
|
@ManyToOne(fetch = FetchType.LAZY)
|
|
@JoinColumn(name = "book_id")
|
|
private ProxyBook book;
|
|
|
|
protected ProxyReview() {
|
|
// JPA
|
|
}
|
|
|
|
public ProxyReview(String comment, ProxyBook book) {
|
|
this.comment = comment;
|
|
this.book = book;
|
|
}
|
|
|
|
public Long getId() {
|
|
return id;
|
|
}
|
|
|
|
public String getComment() {
|
|
return comment;
|
|
}
|
|
}
|