-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: nor Callback nor Listener does not work
PostPosted: Tue Jan 10, 2006 6:26 am 
Newbie

Joined: Thu Oct 20, 2005 4:15 am
Posts: 8
Hibernate version: 3.1RC2

Object class:

Code:
//$Id: Company.java,v 1.1 2005/05/12 13:33:52 epbernard Exp $
package org.hibernate.test.annotations;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;


/**
* Corporate like Air France
*
* @author Emmanuel Bernard
*/
@Entity(name="Corporation")
@EntityListener(Audit.class)
public class Company implements Serializable {
   private Integer id;
   private String name;
    private Flight flight;
    protected boolean updated = false;

    @Id(generate = GeneratorType.AUTO)
    public Integer getId() {
        return id;
    }

   public String getName() {
      return name;
   }

    @OneToOne( cascade = {CascadeType.REMOVE}, fetch = FetchType.LAZY)
    @JoinColumn(name = "comp_id")
    public Flight getFlight() {
        return flight;
    }

    public void setFlight(Flight flights) {
        this.flight = flights;
    }

   public void setId(Integer integer) {
      id = integer;
   }


   public void setName(String string) {
      name = string;
   }

    @PrePersist
    @PreUpdate
    public void testCallbacks(){
        updated = true;
    }

    @Transient
    public boolean isUpdated() {
        return updated;
    }

}


Code between sessionFactory.openSession() and session.close():
Code:
   comp = new Company();
        comp.setName(java.util.UUID.randomUUID().toString());
        Flight flight = new Flight();
        flight.setName(java.util.UUID.randomUUID().toString());
        flight.setDepartureDates(new LinkedList<DepartureDate>());
        for (int j = 0; j < 3; j++) {
            DepartureDate date = new DepartureDate();
            date.setDate(new Date());
            date.setDescription(java.util.UUID.randomUUID().toString());
            flight.getDepartureDates().add(date);
        }
        comp.setFlight(flight);


        long tickStart = System.currentTimeMillis();
        tx.begin();
        try {
            flight = em.merge(comp.getFlight());
            comp.setFlight(flight);
            comp = em.merge(comp);
        }
        catch (Exception e) {
            tx.rollback();
            throw e;
        }

        if (!comp.isUpdated()){
            throw new RuntimeException("Callbacks was not called!!!!");
        };
        tx.commit();
        em.close();


Full stack trace of any exception that occurs:
Exception in thread "main" java.lang.RuntimeException: Callbacks was not called!!!!
at org.hibernate.test.annotations.MyDomainEntityManagerTest.testEntityManagerBulk(MyDomainEntityManagerTest.java:66)
at org.hibernate.test.annotations.MyDomainEntityManagerTest.main(MyDomainEntityManagerTest.java:82)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:86)

Name and version of the database you are using:
HSQL Database Engine Driver, version: 1.7.3

I'm using J2SE EntityManager
Code:


Top
 Profile  
 
 Post subject: UPDATE, UPDATE UPDATE
PostPosted: Wed Jan 11, 2006 5:54 am 
Newbie

Joined: Thu Oct 20, 2005 4:15 am
Posts: 8
Anyone with same troubles upgrade to 3.1 final and lates HA and HEM!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 12, 2006 3:01 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Is it related to http://opensource2.atlassian.com/projects/hibernate/browse/EJB-93

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.