Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EclipseLink less than clause doesn't work correctly
icon6.gif  EclipseLink less than clause doesn't work correctly [message #1717286] Fri, 11 December 2015 12:57
Adi Bogdan is currently offline Adi BogdanFriend
Messages: 1
Registered: December 2015
Junior Member
I'm facing with a strange situation when i use named query or native query to filter data using less than '<' or greater than '>' sign. For example i have a catalog of codes and i make a navigation through this codes and for the firs code that is " 000481" the next code is "-PR. 2L"(this is correct) but the previous of the "-PR. 2L" is "PR. 2L" not " 000481" how is correctly.

If i run the query through the Execute Command... the result is correct. If is important i use Mssql 2005 server and for the persistance EclipseLink jpa 2.1

I think the problem is because of - sign that is in the cod "-PR. 2L"

Thanks in advanced!

@SuppressWarnings("unchecked")
public Cods previous(String cod, String codUnit) {
    EntityManager em = getEntityManager();
    em.setProperty("codUnit", codUnit);
    Query query = em.createQuery("SELECT c FROM Cods c WHERE c.cod < :cod ORDER BY c.cod DESC");
    query.setParameter("cod", cod);
    Cods p = null;
    try {
        List<Cods> lP = query.setMaxResults(1).getResultList();
        if (!lP.isEmpty()) {
            p = (Cods) lP.get(0);
        }
    } finally {
        em.close();
    }


    return p;
}
Previous Topic:Keyword search on MySQL database in JPA
Next Topic:Natural identifier
Goto Forum:
  


Current Time: Thu Apr 18 11:39:31 GMT 2024

Powered by FUDForum. Page generated in 0.01360 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top