2 Replies Latest reply: Jul 20, 2009 6:02 PM by Greybird-Oracle RSS

    References to entities are not allowed

    3962
      I have a couple classes defined like this

      @Entity
      public final class Record {
      @PrimaryKey(sequence = "ID")
      private long id;

      private final Map<String, Result> results;
      }

      @Persistent
      public final class Result {
      private final Record record;
      ...
      }

      and when I try and write a record to the primary index I get the following exception.

      Caused by: java.lang.IllegalArgumentException: References to entities are not allowed: data.Record
           at com.sleepycat.persist.impl.RecordOutput.writeObject(RecordOutput.java:94)
           at com.sleepycat.persist.impl.ReflectionAccessor$ObjectAccess.write(ReflectionAccessor.java:369)
           at com.sleepycat.persist.impl.ReflectionAccessor.writeNonKeyFields(ReflectionAccessor.java:249)
           at com.sleepycat.persist.impl.ComplexFormat.writeObject(ComplexFormat.java:517)

      The Record referenced in the Result is always the same Record as the one being written. I see the rational for the restriction for not allowing references to other entities but why not the same entity already being serialized?

      Thanks,

      Trevor
        • 1. Re: References to entities are not allowed
          Greybird-Oracle
          Hi Trevor,

          There is no reason we could not support this, and in fact we have it on our enhancement list for a future release. We'll keep your request in mind when prioritizing.

          --mark                                                                                                                                                                                                                                                                                                                                                                                           
          • 2. Re: References to entities are not allowed
            Greybird-Oracle
            For future reference, the ticket # for this enhancement is #17525.
            --mark