Hibernate annoation (five components)

Source: Internet
Author: User

For example: There are three classes a B C eventually to be persisted class is a and B C both as components within and a b,c are declared as a component using @embeddable annotations

Class A Code:

Java code

@Entry 
public class A{
private int id
private B b
private C c
...


public B getB(){
 ...
}

public C getC(){

....
}

}

B contains C

Class B

Java code

@Embeddable 
public class B{
  private Stirng bname
  private C c
  get set....
 }

Class C

Java code

@Embeddable 
public class C{
 private String cnam2

  get set....
 }

Persistence does not repeat the Cnam of C to two fields if necessary:

Use in a:

 @Enumerated
 @AttributeOverrides(
  {@AttributeOverride(name="bname",column = @Column(name="cname1") )}
  )

So cname will be colored again as a field cnam1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.