Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Possible bug retrieving single Boolean column
Possible bug retrieving single Boolean column [message #635151] Mon, 25 October 2010 18:53 Go to next message
Brendan Healey is currently offline Brendan Healey
Messages: 12
Registered: May 2010
Junior Member
Hi, this is a funny one, when the value of the testBoolean
column for row "testuser" is false this named query
works ok, when it's true I get NoResultException. A bug?

@NamedQuery(name = "User.Test", query = "SELECT u.testBoolean FROM User u WHERE u.userName = ?1"),
@Column(name = "testBoolean")
    private Boolean testBoolean = false;

Query query = em.createNamedQuery("User.Test");
        query.setParameter(1, "testuser");

        try {
            result = (Boolean) query.getSingleResult();
        } catch (NoResultException e) {
            result = null;

EclipseLink, version: Eclipse Persistence Services - 2.0.1.v20100213-r6600

MySql 5.1.50-community

Re: Possible bug retrieving single Boolean column [message #635329 is a reply to message #635151] Tue, 26 October 2010 12:59 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1023
Registered: July 2009
Senior Member
Hello Brendan,

Feel free to file one, but I'm not sure you should be using getSingleResult() as it cannot distinguish between a null value and no values being returned. Try using getResultLitst(), but you will still get null values in the collection.

The problem is that you are defaulting the testBoolean value to false. Check the value in the database, but I believe that when you are persisting a value of false nothing is being sent to the database because nothing has changed. So the database column remains null. Try leaving the testBoolean uninitialized in the default constructor, and instead set it in other constructors and/or application code. This will cause EclipseLink to see that it has been set and persist a value to the database.

Best Regards,

[Updated on: Tue, 26 October 2010 13:00]

Report message to a moderator

Re: Possible bug retrieving single Boolean column [message #635882 is a reply to message #635151] Thu, 28 October 2010 13:36 Go to previous message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

That is very odd.

What SQL is generated, if you execute the same SQL what result do you get?

(FYI initializing your field to false should not have any issues, and should not affect what is inserted).

James : Wiki : Book : Blog : Twitter
Previous Topic:OneToOne + MySQL issue
Next Topic:Trouble converting SQL into JPQL with OUTER JOIN
Goto Forum:

Current Time: Mon Sep 22 20:24:13 GMT 2014

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

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