Tuesday, 19 January 2016

Embedded entity

Hi another  time. It pass a while when I was writing last time. Today I used one features of jpa2. I used embedded class. I n my project I have two tables with similar business data. I don't like duplicate code so I used embeddable attribute. I moved business attributes to new class and deploy on server. The I crash with problem. The application throw an exception. It couldn't map embedded class with database table. I searched on Google some solution but I couldn't find any thing easy to use.
Many pasts on stackflow described OverwriteAttribute annotation which required in main class mapping from attribute to table column.
Then I observed that not all attributes gave prefix of main class attribute. That attributes of embedded class had defined column name in parameter of @Collumn. So I named rest of attributes and fix problem without changing column names.

No comments:

Post a Comment