-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
회원 탈퇴 기능을 기획하고 구현한다. #740
Comments
|
엔티티 하나에 여러 테이블 매핑
@SecondaryTable(
name = "member_information",
pkJoinColumns = [PrimaryKeyJoinColumn(name = "member_id")],
)
@Entity
class Member(
@Embedded
var information: MemberInformation,
id: Long = 0L,
) : BaseRootEntity<Member>(id)
@Embeddable
data class MemberInformation(
@Column(nullable = false, table = "member_information")
val email: String,
@Column(nullable = false, table = "member_information", length = 30)
val name: String,
) @SecondaryTable(
name = "member_information",
pkJoinColumns = [PrimaryKeyJoinColumn(name = "member_id")],
)
@Entity
class Member(
@AttributeOverrides(
AttributeOverride(name = "email", column = Column(nullable = false, table = "member_information")),
AttributeOverride(name = "name", column = Column(nullable = false, table = "member_information", length = 30)),
)
@Embedded
var information: MemberInformation,
id: Long = 0L,
) : BaseRootEntity<Member>(id)
@Embeddable
data class MemberInformation(
@Column(nullable = false)
val email: String,
@Column(nullable = false, length = 30)
val name: String,
)
Good @Embeddable
data class MemberInformation(
@Column(nullable = false, table = "member_information")
val email: String,
@Column(nullable = false, length = 30)
val name: String,
) Bad @Embeddable
data class MemberInformation(
@Column(nullable = false)
val email: String,
@Column(nullable = false, table = "member_information", length = 30)
val name: String,
) ComponentPropertyHolder.java#L280-L298 /*
* Check table matches between the component and the columns
* if not, change the component table if no properties are set
* if a property is set already the core cannot support that
*/
if (columns != null) {
Table table = columns[0].getTable();
if ( !table.equals( component.getTable() ) ) {
if ( component.getPropertySpan() == 0 ) {
component.setTable( table );
}
else {
throw new AnnotationException(
"A component cannot hold properties split into 2 different tables: "
+ this.getPath()
);
}
}
}
@SecondaryTable(
name = "member_information",
pkJoinColumns = [PrimaryKeyJoinColumn(name = "member_id")],
foreignKey = ForeignKey(name = "fk_member_information_member_id_ref_member_id"),
)
@org.hibernate.annotations.Table(appliesTo = "member_information", optional = false) 참고 자료 |
@SecondaryTable -> @OnetoOne
|
관련 이슈: #359
The text was updated successfully, but these errors were encountered: