Tapestry
  1. Tapestry
  2. TAPESTRY-2339

The automatic ValueEncoder for Hibernate entities will sometimes encode an entity as null (rather than its primary key)

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 5.0.11
    • Fix Version/s: 5.0.12
    • Component/s: tapestry-hibernate
    • Labels:
      None

      Description

      Still trying to figure out under which circumstances this can occur. It may be a Hibernate problem.

        Activity

        Hide
        Howard M. Lewis Ship added a comment -

        Not sure if it is user error or Hibernate's, but it looks like our code that gets a property accessor from Hibernate gets one of these:

        org.hibernate.property.DirectPropertyAccessor$DirectGetter

        And the implementation:

        public Object get(Object target) throws HibernateException {
        try

        { return field.get(target); }

        catch (Exception e)

        { throw new PropertyAccessException(e, "could not get a field value by reflection", false, clazz, name); }

        }

        The object in question has been enhanced by CGLIB, but I think direct field access may not be the right approach even then, since field access should not be something that can trigger lazy loading of data into fields.

        I'm going to try switching some of this logic over to Tapestry's PropertyAccessor instead.

        Show
        Howard M. Lewis Ship added a comment - Not sure if it is user error or Hibernate's, but it looks like our code that gets a property accessor from Hibernate gets one of these: org.hibernate.property.DirectPropertyAccessor$DirectGetter And the implementation: public Object get(Object target) throws HibernateException { try { return field.get(target); } catch (Exception e) { throw new PropertyAccessException(e, "could not get a field value by reflection", false, clazz, name); } } The object in question has been enhanced by CGLIB, but I think direct field access may not be the right approach even then, since field access should not be something that can trigger lazy loading of data into fields. I'm going to try switching some of this logic over to Tapestry's PropertyAccessor instead.
        Hide
        Howard M. Lewis Ship added a comment -

        Yep, switching to Tapestry's PropertyAccess code (which will invoke the getter, rather than reading the field) did the trick. Still not sure if this represents a bug in Hibernate or just user error on our part, but it works and that's what counts.

        Show
        Howard M. Lewis Ship added a comment - Yep, switching to Tapestry's PropertyAccess code (which will invoke the getter, rather than reading the field) did the trick. Still not sure if this represents a bug in Hibernate or just user error on our part, but it works and that's what counts.
        Hide
        Howard M. Lewis Ship added a comment -

        FYI: This problem manifested itself only once I started using @ManyToOne(fetch = FetchType.LAZY) for a large number of relationships.

        Show
        Howard M. Lewis Ship added a comment - FYI: This problem manifested itself only once I started using @ManyToOne(fetch = FetchType.LAZY) for a large number of relationships.

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Howard M. Lewis Ship
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development