2012-11-29 42 views

回答

3

persistence.xml中沒有這樣的屬性。通過EclipseLink和其他JPA實現,它們在orm.xml中定義(或在其他文件中由mapping-file元素persistence.xml引用),如下所示:

<persistence-unit-metadata> 
    <persistence-unit-defaults> 
    <entity-listeners> 
     <entity-listener class="somepackage.YourListener"> 
     <pre-persist method-name="method1"/> 
     <post-persist method-name="method2"/> 
     <pre-remove method-name="method3"/> 
     <post-remove method-name="method4"/> 
     <pre-update method-name="method5"/> 
     <post-update method-name="method6"/> 
     <post-load method-name="method7"/> 
     </entity-listener> 
     <entity-listener class="other"> 
     <pre-persist method-name="someMethod"/>    
     </entity-listener> 
    </entity-listeners> 
    </persistence-unit-defaults> 
</persistence-unit-metadata> 
相關問題