users@glassfish.java.net

Why does @OrderBy add UPPER() to order by clause?

From: <forums_at_java.net>
Date: Mon, 26 Sep 2011 15:26:03 -0500 (CDT)

Hi there. I hope I've got the right forum to ask this.

I'm using Toplink Essentials and the documentation states that if you add the
@OrderBy annotation without any parameters it will use the primary key. When
it produces the SQL for fetching the list Toplink Essentials wraps each field
that is in my compound prmary key with UPPER() which my database (InterBase)
doesn't support. Why and how can I stop it? As an alternative I tried
specifying the fields in my primary key, eg.
    @OrderBy("itemPK.jobNo, itemPK.itemNo")
and that doesn't work either.

Any advice? I'm getting desperate.

Here's a snippet of code:

@Entity
public class Job {
    // ...
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "jobs")
    @OrderBy
    private List<Item> itemList;
    // ...
}

@Embeddable
public class ItemPK {
    @Column(name = "JOB_NO", nullable = false)
    private int jobNo;
    @Column(name = "ITEM_NO", nullable = false)
    private int itemNo;
    // ...
}

@Entity
public class Item {
    // ...
    @EmbeddedID
    protected ItemPK itemPK;
    // ...
    @JoinColumn(name = "JOB_NO", referencedColumnName = "JOB_NO",
insertable = false, updatable = false)
    @ManyToOne
    private Job job;
    // ...
}

Regards,
Stephen.

 


--
[Message sent by forum member 'Steve_X']
View Post: http://forums.java.net/node/847306