I have this object
@Entity
public class Cat {
@Id String name;
Fur fur;
}
public class Fur {
String color1;
String color2;
}
How do I map it to:
Name Color1 Color2
+---------+------+------+
|SnowBall |red |green |
+---------+------+------+
|Snowball2|white |black |
+---------+------+------+
I only have JPA 2.1
You could use @Embeddable
and @Embedded
JPA annotations.
@Entity
public class Cat {
@Id String name;
@Embedded
Fur fur;
}
@Embeddable
public class Fur {
String color1;
String color2;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.