java - Separating JPA information from POJO -


i working on project have entities persisted database using jpa. using maven project management framework. wondering if possible create 1 project pojos , persistence definitions , "combine" 2 single output contains pojos , persistence information.

basically trying separate code pojos persistence definition. because pojos may reused several different projects may or may not need persist them , may or may not want change persistence information. (similar not quite same is possible build jpa entity extending pojo?)

i have 2 ideas on how might able it. if use pojos in web application provide persistence.xml , map classes in project , add dependency project containing pojos. if wanted create single jar file containing persistence information , pojos, think use shade plugin?

is there other way merge 2 maven projects single output , reasonable thing want do?

if remember correctly, annotations not have on classpath if you're not using them. annotated classes can still loaded.

so recommendation be:

  • stick jpa annotations, easiest way define mappings , tooling support better.
  • declare jpa dependencies optional , provided.
  • if need override mappings defined annotations, should possible using persistence.xml, afaik (never tried).

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -