我刚刚搜索了eclipselink的动态映射,我找不到解决方案,现在在我的系统中,一个实体有3个版本,一个是工作/草稿(即W100),另一个是生产(即M100),其余一个是历史版本(H100),在任何时候,我们都可以访问工作,生产和历史版本。 即将一个实体动态映射到多个表
Account account = // query from working.
account.setStatus("APPROVED");
account.increaseVersionNo();
myJPAEngine.updateApproved(account); // this step update status to both working and production
//, and W100.PRODUCTION_IPKEY = M100.IPKEY
// (if production version does't exist
//, create a new one with same columns as working version).
//, if increaseVersionNo() called, then we need copy old 'M'- production record to 'H' history version table.
//, my JPA engine need access both 'W'/'M'/'H' tables at same time by passing a parameter to JPA API metadata classes by ThreadLocal or other related workaround.
是否的EclipseLink(或休眠)支持此?我的动态映射接受一个参数来决定使用哪个表,也就是说这是一个交互式动态映射。 可以和我们如何在eclipselink元数据类中插入一些定制?
谢谢。
“更新”操作可以使用“原生更新”功能? 我想插入我的自定义到JPA元数据API类,但我不确定这一点。 –
是的,您可以使用不带类参数的变体:'createNativeQuery(java.lang.String sqlString)' – gerrytan