سؤال

I have a EntityListener that needs to be configurable (typical data source info: driver, user, password), but I´d like to avoid adding one more properties file to the project. Is there any way to retrieve from some standard configuration place such as web.xml? It seems that injection via @Resource will be only available in JPA 2.1 (I am using JPA 2.0).

UPDATE - to make this clear

In my entity bean, I have an annotation @EntityListeners(MyEntityListener.class). So MyEntityListener may have methods annotated with @PostPersist for example. When my entity bean is gonna be persisted, this method is called. What I want is to retrieve the data for MyEntityListener initialization without using another configuration file.

هل كانت مفيدة؟

المحلول

http://openjpa.apache.org/builds/2.2.1/apidocs/org/apache/openjpa/audit/Auditor.html does the trick. It works (my bad, it was a misconfiguration of mine). Actually it works pretty well.

<property name="openjpa.Auditor" value="com.acme.Auditor(param2=10,param2='hello')"/>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top