My workaround (needs to be deeply tested):

Klesk wrote
>     @Test
>     public void testProxy() throws Exception {
>         final EntityManager em = factory.createEntityManager();
>         final SUti entity = em.find(SUti.class, 1);
> 
>         final ProxyFactory proxiter = new ProxyFactory();
>         proxiter.setSuperclass(entity.getClass());
>         proxiter.setHandler((instance, method, wrapper, args) -> {
>             instance = entity;
>             wrapper = entity.getClass().getMethod(method.getName(),
> method.getParameterTypes());
>             if(method.getName().startsWith("set")) {
>                 final String methodName = method.getName();
>                 final Object previous =
> instance.getClass().getMethod("get" +
> methodName.substring(3)).invoke(instance);
>                 System.out.println("changed: " + previous + " -> " +
> args[0]);
>             }
>             return wrapper.invoke(instance, args);
>         });
> 
>         final SUti mock = (SUti) proxiter.create(new Class[0], new
> Object[0]);
>         assertEquals("AAAA", entity.getUtLibuti());
>         assertEquals("AAAA", mock.getUtLibuti());
>         mock.setUtLibuti("test");
>         assertEquals("test", entity.getUtLibuti());
>         assertEquals("test", mock.getUtLibuti());
>     }





--
View this message in context: 
http://openjpa.208410.n2.nabble.com/Attribut-change-listener-tp7590226p7590227.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to