Note that there are some explanatory texts on larger screens.

plurals
  1. POObjectDB, failed to write the value of field (error 363)
    text
    copied!<p>I'm trying to make an application that can store a tree structure with files and folders in an ObjectDB database (embedde), but even with a simple test I keep getting an error...</p> <h2>Entity classes</h2> <p><strong>Node.java</strong></p> <pre><code>@MappedSuperclass public abstract class Node { @Column(name = "Name", nullable = false) private String name; @Column(name = "Parent_FK") @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "FolderID", nullable = true) private FolderNode parent = null; public Node() { } public Node(String name) { this.name = name; } public String getName() { return name; } public void setName(String name) { this.name = name; } public boolean hasParent() { return (parent != null); } public FolderNode getParent() { return parent; } void setParent(FolderNode parent) { this.parent = parent; } @Override public int hashCode() { return new HashCodeBuilder(17, 31).append(name).toHashCode(); } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (obj instanceof Label) { // TODO is instanceof enough?? Label other = (Label) obj; return name.equals(other.getName()); } return false; } } </code></pre> <p><strong>FolderNode.java</strong></p> <pre><code>@Entity(name = "Folders") public class FolderNode extends Node { @Column(name = "FolderID") @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; @OneToMany(cascade = CascadeType.ALL, mappedBy = "parent", fetch = FetchType.LAZY, orphanRemoval = true) private Set&lt;Node&gt; children = new HashSet&lt;Node&gt;(); public FolderNode() { } public FolderNode(String name) { super(name); } public Set&lt;Node&gt; getChildren() { return children; } public void setChildren(Set&lt;Node&gt; children) { this.children = children; } public long getId() { return id; } public void setId(long id) { this.id = id; } } </code></pre> <h2>Calling code</h2> <pre><code>//Init EntityManagerFactory emf = Persistence.createEntityManagerFactory("database.odb"); EntityManager em = emf.createEntityManager(); //Create object FolderNode rootFolder = new FolderNode("root"); //Persist em.getTransaction().begin(); em.persist(rootFolder); em.getTransaction().commit(); em.close(); emf.close(); emf = Persistence.createEntityManagerFactory("database.odb"); em = emf.createEntityManager(); TypedQuery&lt;FolderNode&gt; query = em.createQuery("SELECT f FROM Folders f", FolderNode.class); List&lt;FolderNode&gt; result = query.getResultList(); </code></pre> <p>And that's where it crashes with an exception:</p> <pre><code>[ObjectDB 2.3.5_07] javax.persistence.PersistenceException Failed to write the value of field field FolderNode.children using reflection (error 363) </code></pre> <p>The problem seems to go away if I don't close and reopen the EntityManagerFactory and EntityManager before fetching the object.</p> <p>What am I missing here?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload