Reputation: 7707
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
Upvotes: 2
Views: 1007
Reputation: 5318
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;
}
Upvotes: 4