• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

retriving null object with another value object through expressions

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,

kindly i am working on retrieving data from the database; i want to get from indexStatusTypeId column the row(object) when it equal to 1 or empty (null), but when i ran the following code it just retrive objects equal to 1, it does not retrieve the null ones

Expression exp = new ExpressionBuilder();
Expression expTwo = new ExpressionBuilder();
exp = exp.get("indexStatusType").get("indexStatusTypeId").notEqual(2);
expTwo = expTwo.get("indexStatusType").get("indexStatusTypeId").notEqual(3).and(exp);

thank you

 
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch, Mohammad .

What product are you using to talk to the database?
 
Mohammad Noor Najdawi
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am working on eclipselink with a GeneralDAO API
 
Mohammad Noor Najdawi
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
GeneralDAO is an API used localy in my place(work)
 
Jan Cumps
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have moved this post to our Object Relational Mapping forum for you.
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see a test for null, just a bunch of not equals tests. They are not the same thing.
 
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The get("indexStatusType") call implies a join, in the database this will filter out null results.

To avoid this you must use an outer join in the database, to do this use,

getAllowingNull("indexStatusType")

 
Mohammad Noor Najdawi
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
the indexStatusType is object in table has indexStatusTypeId of type long, and this attribute in database has the following values: 1,2,3, empty(null) i had write the previous code supposing to get notEqual(2) and notEqual(3), but i got only the equal (1) result.

i am also trying to write the following
Expression exp;
ExpressionBuilder builder = new ExpressionBuilder();
Expression expTwo;
ExpressionBuilder builderTwo = new ExpressionBuilder();
exp = builder.get("indexStatusType").isNull();
expTwo = builderTwo.get("indexStatusType").get("indexStatusTypeId").equal(1).or(exp);

and then get the result of expression expTow, but also i get the only the result of equal(1). although when i get the equal(null) or isNull() only in a get statement it work, but if i or it with another expression it return the another value not the null one.

i think the problem in or, may be the or here between object of type IndexStatusType and indexStatusTypeId which is long
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic