Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Texo/Hibernate] createQuery() returns 0 results but raw SQL works
[Texo/Hibernate] createQuery() returns 0 results but raw SQL works [message #698609] Tue, 19 July 2011 15:54 Go to previous message
Mike Cooper is currently offline Mike Cooper
Messages: 39
Registered: February 2011
Member
I have a strange situation where I'm doing a lookup of a value using createQuery() which is returning 0 results, yet if I execute the raw SQL provided by Hibernate sql_show=true it works fine.

Here's the code:
Query query = session.createQuery("FROM RegistrationCode WHERE Code='" + name + "'");
List<?> regCodes = query.list();
if (regCodes == null) {
	    log.debug(m, "No regCode with Code=<%s> found", name);
	    return null;
}
// Should only be 1 match if success
log.debug(m, "Found %d matches for code=<%s>", regCodes.size(), name);


In this code the name variable is set to something like "G8KA-38D4-C2KH". The debug output looks like:

INFO: 2011-07-19 11:23:24,526 DEBUG [vortex.reg.RegCodeManagerPersist] getByCode: Get regCode with Code=<G8KA-38D4-C2KH>
INFO: Hibernate: select registrati0_.dbID as dbID14_, registrati0_.dbVersion as dbVersion14_, registrati0_.code as code14_, registrati0_.created as created14_, registrati0_.creator_dbID as creator17_14_, registrati0_.description as descript5_14_, registrati0_.devType as devType14_, registrati0_.devVendorModel as devVendo7_14_, registrati0_.devVendorName as devVendo8_14_, registrati0_.mobileRadioType as mobileRa9_14_, registrati0_.name as name14_, registrati0_.osName as osName14_, registrati0_.phoneNumber_dbID as phoneNu18_14_, registrati0_.status as status14_, registrati0_.updated as updated14_, registrati0_.useCountMax as useCoun14_14_, registrati0_.validStart as validStart14_, registrati0_.validUntil as validUntil14_ from RegistrationCode registrati0_ where Code='G8KA-38D4-C2KH'
INFO: 2011-07-19 11:23:24,532 DEBUG [vortex.reg.RegCodeManagerPersist] getByCode: Found 0 matches for code=<G8KA-38D4-C2KH>


If I take the SQL in the "INFO: Hibernate: select ..." line and execute directly on the database (mysql) it finds the given entry just fine.

The database is mysql 5.0. Using the latest version of Texo and Hibernate as of 7/19/2011.

Any suggestions?
 
Read Message
Read Message
Read Message
Previous Topic:[Texo/Hibernate] Can I specify a different name for database table name?
Next Topic:[EMF Compare] Visibility of StatisticBasedSimilarityChecker
Goto Forum:
  


Current Time: Fri May 24 15:45:11 EDT 2013

Powered by FUDForum. Page generated in 0.01685 seconds