Is it possible for a entity to contain multiple fields of the same embeddable? #1381
-
Hi, and thank you for the great work on Doma. I really enjoy using it! 😊 import org.seasar.doma.Embeddable;
import org.seasar.doma.Entity;
import org.seasar.doma.Id;
@Entity
record Person(
@Id Integer id,
Address homeAddress,
Address workAddress) {
}
@Embeddable
record Address(
String city,
String street,
String zip) {
} I’d like to create an entity class like the one above. Ideally, I’m hoping for something along these lines: import org.seasar.doma.Embeddable;
import org.seasar.doma.Entity;
import org.seasar.doma.Id;
@Entity
record Person(
@Id Integer id,
@EmbeddablePrefix("home") Address homeAddress,
@EmbeddablePrefix("work") Address workAddress) {
}
@Embeddable
record Address(
String city,
String street,
String zip) {
} Any guidance would be greatly appreciated. Thank you! |
Beta Was this translation helpful? Give feedback.
Answered by
nakamura-to
Jul 5, 2025
Replies: 1 comment 4 replies
-
Hmmm… perhaps I really should normalize it properly after all. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mazeneko We’re planning to introduce
@Embedded
in PR #1384 to allow you to specify a prefix. Here’s an example of how it will work:This creates columns: billing_street, billing_city, billing_zip_code, shipping_street, shipping_city, shipping_zip_code.
Would this feature meet your needs? Please feel free to leave any comments or questions.