Fields in objects not populated in query result.

#1

When I run the following Java code

TypedQuery<Folder> rootFolderQuery = this.entityManager.createQuery("SELECT f FROM Folder f WHERE f.parent IS NULL", Folder.class);
final List<Folder> resultList = rootFolderQuery.getResultList();

none of the Folder objects has its fields populated. Running the same query from the Explorer gives the results as expected. Any ideas what I'm doing wrong? This code had worked at some point in the past, but may have been a victim of an objectDB upgrade.

#2

A possible reason could be a partial enhancement. ObjectDB can populate fields in both enhancement mode and reflection mode but mixing modes is not supported and if some classes in the hierarchy are enhanced and some are not this could happen.

Note also that null values are expected when viewing fields in the debugger before they are  accessed.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#3

A bit more context on this. Here's the classes in question:

@Entity
@Getter
@Setter
public class Folder extends Entry implements Serializable {
   /**
    * 
    */
   private static final long serialVersionUID = 1L;
 
   @OneToMany(cascade=CascadeType.ALL) private Map<String,Entry> children = new TreeMap<>();
   
   private String path;
   

     [assorted code for managing folders]

}

@Entity
@Getter
@Setter
public class Entry implements Comparable<Entry>, Serializable {

   /**
    * 
    */
   private static final long serialVersionUID = 1L;
   
   @GeneratedValue
   @Id protected long id;
   private String name;
   private String description;
   @ManyToOne(cascade=CascadeType.PERSIST) 
   private Folder parent;
   private boolean listable;
   @ManyToMany(cascade=CascadeType.ALL) 
   private Map<Folder, String> shadowParents = new HashMap<>();
   

     [assorted  code common to entities]

}

No fields which are @Entitys are loaded from the database. I don't specify Enhancement mode or Reflection mode anywhere.

-dh

#4

It is unclear why you are having these issues.

Please provide a minimal runnable sample program to demonstrate this problem. Follow these instructions regarding the source code format.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply

To post a reply and/or subscribe to update notifications - please login