我正在使用 EclipseLink,我必须在 oracle 中进行审核,因此我可以使用纯 JDBC 进行审核,V$session
并且我可以通过这种方式在 oracle 中审核应用程序名称,但是在 EclipseLink JPA 中我无法设置要审核的应用程序名称,方式我一直在尝试的是通过动态设置我想要使用的会话参数,SessionCustomizer
但它没有做应该做的事情......没有显示错误,但没有审核oracle中的名称......我有时间在这个问题上挣扎没有结果,我使用的代码是:
定制器类是:
package com.util;
import org.eclipse.persistence.config.SessionCustomizer;
import org.eclipse.persistence.sessions.Session;
public class ProgramCustomizer implements SessionCustomizer {
public void customize(Session s) throws Exception {
//s.getDatasourceLogin().setProperty("v$session.program","Employees"); //tried with this method
//s.getLogin().setProperty("v$session.program","Employees"); //tried with this one as well
}
}
通过使用上面应该工作的注释行之一,没有工作......
还尝试将这些行更改为这些行:
DatabaseLogin login= (DatabaseLogin) s.getDatasourceLogin();
login.setProperty("v$session.program","Clients");
也没有工作。
我正在阅读 Eclipse 链接http://wiki.eclipse.org/Configuring_a_Session_(ELUG)并以这种方式完成...
编辑方法是:
public void edit(Employee employee) {
emProperties.put(PersistenceUnitProperties.SESSION_CUSTOMIZER, "com.util.ProgramCustomizer");
factory = Persistence.createEntityManagerFactory("EJBLocalPU", emProperties);
em = factory.createEntityManager();
em.merge(employee);
}
它很好地执行了合并,但不会将我想要的应用程序名称审核到数据库中。
您对如何解决此问题有任何想法。