I got a legacy database domain I can't change but it was possible conceive a domain entity to address my problema.
Legacy Tables: TABLE1(ID,VALUE) TABLE2(ID,DATE) TABLE3(ID,DESCRIPTION)
Domain: NewConceptDomain { int value; Date date; String description; }
How can I map new NewConceptDomain using JPA?
You can have multiple one-to-many associations, as long as only one is EAGER.
In Spring Data JPA we can map an entity to a specific table by using @Table annotation where we can specify schema and name. But Spring Data JDBC uses a NamingStrategy to map an entity to a table name by converting the entities class name.
Use @SecondaryTable
(http://en.wikibooks.org/wiki/Java_Persistence/Tables#Multiple_tables)
@Entity
@Table(name="TABLE1")
@SecondaryTables({
@SecondaryTable(name="TABLE2",
pkJoinColumns = @PrimaryKeyJoinColumn(name="ID", referencedColumnName="ID")
),
@SecondaryTable(name="TABLE3",
pkJoinColumns = @PrimaryKeyJoinColumn(name="ID", referencedColumnName="ID")
)}
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With