Listener pre-update

2 respostas
J

gente, eu to tentando usar os entity-listeners mas to tendo um probleminha …

meu orm.xml

<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
                 version="1.0"
        >
            <persistence-unit-metadata>
        <persistence-unit-defaults>
        
          <entity-listeners>
    <entity-listener class="org.jboss.seam.example.jpa.ListenerApp">
    <post-update method-name="posupdate"/>
   
                              
    </entity-listener>
    </entity-listeners>	   
   </persistence-unit-defaults>
    </persistence-unit-metadata>
 
</entity-mappings>

funciona bunitinho :slight_smile:

mas se eu adiciono um listener a tag pre-update …

<entity-listener class="org.jboss.seam.example.jpa.ListenerApp">
    <post-update method-name="posupdate"/>
   <pre-update method-name="preupdate"/>
                              
    </entity-listener>

aí não funciona … dá o seguinte erro:

org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element ‘pre-update’. One of ‘{“http://java.sun.com/xml/ns/persistence/orm”:post-load}’ is expected.

minha classe de listener:

package org.jboss.seam.example.jpa;

public class ListenerApp {
	
	
	public void preupdate(Object ob){
		
		System.out.println("será atualizado");
		
	}
	
	
	public void posupdate(Object ob){

		System.out.println("foi atualizado");

	}

}

alguém tem alguma ideia?

OBS: Eu to usando o JBoss Seam, e não EJB puro … pode estar interferindo ( eu acho q não pois tanto com EJB ou Seam eu uso o Hibernate … )

brigadoo :slight_smile:

2 Respostas

Foxlol

Tenta:

<entity-listeners> 
    <entity-listener class="org.jboss.seam.example.jpa.ListenerApp">  
        <post-update method-name="posupdate"/>  
    </entity-listener>

    <entity-listener class="org.jboss.seam.example.jpa.ListenerApp">  
        <pre-update method-name="preupdate"/>  
    </entity-listener>
</entity-listeners>
J

mesmo erro :S

Criado 30 de novembro de 2009
Ultima resposta 1 de dez. de 2009
Respostas 2
Participantes 2