19

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?

1 Answer 1

45

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")
  )}
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.