Creating 1-1 Nested CDT from Existing Tables--Avoiding Extra DB Column in Parent

Hello,

Suppose I have a existing "Person" and "Account" CDTs that use a foreign key.  

Person: id, name, etc...

Account: id, personId, number, etc...

 

I want to create a separate nested CDT that is "Person", but contains "account" information.  I want to be able to reference Person.Account in my cdt, but I do NOT want to add a separate database column.  Is there a JPA annotation I can use in my "person" CDT to link the account data?  I only know how to do this in the other direction (i.e. nest Person in Account).

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer
    Unless your Person CDT/table has a field for accountID your Person CDT cannot be the parent. From what you listed it looks like your parent CDT would be Account and Person would be the nested CDT joined on the personId column.

    Also, if you have a one to many relationship, you should keep cascadeType=REFRESH. If you use cascadeType=ALL and delete the parent entity, all the child entities will also be deleted.
Reply
  • +1
    Certified Lead Developer
    Unless your Person CDT/table has a field for accountID your Person CDT cannot be the parent. From what you listed it looks like your parent CDT would be Account and Person would be the nested CDT joined on the personId column.

    Also, if you have a one to many relationship, you should keep cascadeType=REFRESH. If you use cascadeType=ALL and delete the parent entity, all the child entities will also be deleted.
Children