Menu

Northwind example – Employee EJB lookup

milev_r
2006-01-23
2013-01-13
  • milev_r

    milev_r - 2006-01-23

    Hi,

    It seems that Hybernate has a problem loading the Employee EJB (and also other EJBs that reference this bean).

    If I try to execute:

    Object o = em.find(Employee.class,1);

    I get these messages:
    ---------------------------------
    14:32:28,515 INFO  [STDOUT] Hibernate: select employee0_.employeeID as employeeID2_1_, employee0_.address as address2_1_, employee0_.country as country2_1_, employee0_.region as region2_1_, employee0_.title as title2_1_, employee0_.extension as extension2_1_, employee0_.city as city2_1_, employee0_.postalCode as postalCode2_1_, employee0_.birthDate as birthDate2_1_, employee0_.firstName as firstName2_1_, employee0_.hireDate as hireDate2_1_, employee0_.homePhone as homePhone2_1_, employee0_.lastName as lastName2_1_, employee0_.notes as notes2_1_, employee0_.photo as photo2_1_, employee0_.titleOfCourtesy as titleOf16_2_1_, employee0_.ReportsTo as ReportsTo2_1_, employee1_.employeeID as employeeID2_0_, employee1_.address as address2_0_, employee1_.country as country2_0_, employee1_.region as region2_0_, employee1_.title as title2_0_, employee1_.extension as extension2_0_, employee1_.city as city2_0_, employee1_.postalCode as postalCode2_0_, employee1_.birthDate as birthDate2_0_, employee1_.firstName as firstName2_0_, employee1_.hireDate as hireDate2_0_, employee1_.homePhone as homePhone2_0_, employee1_.lastName as lastName2_0_, employee1_.notes as notes2_0_, employee1_.photo as photo2_0_, employee1_.titleOfCourtesy as titleOf16_2_0_, employee1_.ReportsTo as ReportsTo2_0_ from employees employee0_ left outer join employees employee1_ on employee0_.ReportsTo=employee1_.employeeID where employee0_.employeeID=?
    14:32:28,531 INFO  [DefaultLoadEventListener] Error performing load command
    org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.lightminds.appletserver.examples.northwind.ejb3.Employee#0]
        at org.hibernate.ObjectNotFoundException.throwIfNull(ObjectNotFoundException.java:27)
    .....
    ----------------------------------

    Perhaps there is there some error in the Employee EJB mappings? Any idea?

    Thanx,
    Roberto

     
    • Peter Salomonsen

      The reason for this is that the Employee table contains a reference to itself by the field "reportsTo". When there is no "reportsTo" it seems like this field is set to zero. And there are no records with this identifier - hence you get the error message.

      I've resolved this by adding lazy loading on this relation (recently committed to cvs). I've also added a test program to retrieve a Employee object based on your example.

      I don't know how this relates to your updating routines - but I suggest rather than accessing the  referenced entity beans directly - you "cascade" your way from the root entity bean of the entitylistmanager. You should be able to save all your updates to all tables just by merging on this one bean (by requiring cascaded updates of course). Then you don't have to figure out all the referenced tables, and you can just find the paths  based on the searchProperty acquired from the EntityListColumn annotations.

      Regards,

      Peter

       

Log in to post a comment.

MongoDB Logo MongoDB