Home » Support » Forum » Problem with @OrderBy

Problem with @OrderBy

#1

When I use @OrderBy and supply multiple order fields I get and error when ObjectDB Explorer expands a instance of the entity.

Example code:

@Entity
@Table(name="Defects", schema = "myDB")
public class Defects  implements Serializable
{
    ...
    ...
    @OneToMany(mappedBy="defect")
    @OrderBy("seqRel, noteSeq")
    Set<Notes> notes;
    ...
    ...
}

The error is printed on the console where I started the Explorer

Th error that seems most informative is:

Exception in thread "AWT-EventQueue-0" [ObjectDB 2.2.1_02] Query:  SELECT owner FROM Notes owner JOIN owner.defect inverse WHERE inverse = ?1 ORDER BY owner.seqRel,  ==> noteSeq <==
javax.persistence.PersistenceException
Unexpected query token 'noteSeq' (error 752)
(position 98) at java.awt.Component.dispatchEventImpl(Component.java:4652)

The error seems to be the second field "noteSeq" in the above example is referenced as if it were an entity instead of a field of an entity.

If I remove the multiple fields and only use one I do not get any errors.

@OrderBy("seqRel")

Is this a bug or am I using collections and JPA annotations in an unsupported way?

#2

Your code demonstrates an ObjectDB bug in handling multiple order expressions in inverse (mapped by) fields.

Version 2.2.2 includes a fix - please try it.

Thank you for your report.

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

2.2.2 fixed the problem


Post Reply

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