-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: ignorecase problem with hsql
PostPosted: Tue Nov 15, 2005 1:44 am 
Beginner
Beginner

Joined: Thu Nov 03, 2005 4:11 pm
Posts: 25
i am aware of the ignoreCase() method using criteria queries. But i thought I could also use standard sql calls like lower when writing queries in straight hsql.

like: select user from User user where lower(username)=?

When i run this query i get a null pointer exception when it is executed. The exception goes away when I remove the "lower" statement. The funny thing is when I am running in debug mode the query is still outputed to the console and it executes fine through my sql tool.

Does lower not work?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 15, 2005 2:02 am 
Beginner
Beginner

Joined: Thu Nov 03, 2005 4:11 pm
Posts: 25
Actually after further testing i also get errors when i run the ignore case method. It seems like there might be bug or something with the ignore case stuff. I am using hibernate 3 with spring and hsqldb. By the way on the previous message i meant to say straight "hql" not "hsql"

Check out my code pretty simple
Code:
Criteria criteria = session.createCriteria(User.class).add(Restrictions.eq("username", userName).ignoreCase()).add(
      Restrictions.eq("password", password));
List results2 = criteria.list();


I get the error on criteria.list() call. If i remove the ignore case it works without error. Again the query output runs fine in my db. here is the error
Code:
Hibernate: select this_.ID as ID0_, this_.VERSION as VERSION50_0_, this_.USERNAME as USERNAME50_0_, this_.PASSWORD as PASSWORD50_0_, this_.SYSTEM_ADMIN as SYSTEM5_50_0_, this_.ACTIVE as ACTIVE50_0_, this_.DEFAULT_COMPANY_ID as DEFAULT7_50_0_, this_.DEFAULT_PHYSICIAN_DATA_GROUP_ID as DEFAULT8_50_0_, this_.FIRST_NAME as FIRST9_50_0_, this_.LAST_NAME as LAST10_50_0_, this_.EMAIL as EMAIL50_0_, this_.PHONE_NUMBER as PHONE12_50_0_, this_.JOB_DESCRIPTION as JOB13_50_0_ from USERS this_ where lower(this_.USERNAME)=? and this_.PASSWORD=? and this_.ACTIVE=?
Exception in thread "main" java.lang.NullPointerException
   at org.hibernate.tuple.AbstractTuplizer.createProxy(AbstractTuplizer.java:249)
   at org.hibernate.persister.entity.BasicEntityPersister.createProxy(BasicEntityPersister.java:2831)
   at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:218)
   at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:163)
   at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79)
   at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:655)
   at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:261)
   at org.hibernate.type.EntityType.resolve(EntityType.java:286)
   at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:105)
   at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:530)
   at org.hibernate.loader.Loader.doQuery(Loader.java:436)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
   at org.hibernate.loader.Loader.doList(Loader.java:1593)
   at org.hibernate.loader.Loader.list(Loader.java:1577)
   at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:111)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1322)
   at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:300)
   at com.smbs.model.dao.implementation.hibernate.security.SecurityDAO$1.doInHibernate(SecurityDAO.java:173)
   at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:315)
   at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:288)
   at com.smbs.model.dao.implementation.hibernate.security.SecurityDAO.findUserByLogin(SecurityDAO.java:160)
   at


Top
 Profile  
 
 Post subject: solution odd
PostPosted: Tue Nov 15, 2005 2:21 am 
Beginner
Beginner

Joined: Thu Nov 03, 2005 4:11 pm
Posts: 25
I found the solution. I have to explicity declare the "type" in the mapping file. This is odd, the type is just a plain old java.lang.String which i thought hibernate mapped automatically and seems to unless i apply this ignore case feature.

I would like to hear any insight anyone can deliver on this issue.


Top
 Profile  
 
 Post subject: Re: solution odd
PostPosted: Tue Nov 15, 2005 2:28 am 
Beginner
Beginner

Joined: Thu Nov 03, 2005 4:11 pm
Posts: 25
bluesky wrote:
I found the solution. I have to explicity declare the "type" in the mapping file. This is odd, the type is just a plain old java.lang.String which i thought hibernate mapped automatically and seems to unless i apply this ignore case feature.

I would like to hear any insight anyone can deliver on this issue.


Actually ignore this last post completely. That didn't make it work, i guess it is just late and i am making dumb mistakes. sorry for the confusion

To restate the problem: as far as i can tell the application of the ignoreCase() or lower in hql causes a null pointer when i execute.


Top
 Profile  
 
 Post subject: maybe the value you provided contains the uppercase
PostPosted: Tue Nov 15, 2005 3:11 am 
Newbie

Joined: Thu Jun 23, 2005 9:23 pm
Posts: 13
maybe the value you provided to the variable "userName" vicontains the uppercase.
best wishes~!!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 15, 2005 12:17 pm 
Beginner
Beginner

Joined: Thu Nov 03, 2005 4:11 pm
Posts: 25
why would that cause a null pointer exception?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 15, 2005 5:39 pm 
Beginner
Beginner

Joined: Thu Nov 03, 2005 4:11 pm
Posts: 25
solved this problem it was actually an issue with an association mappping in this class. I got to say debugging mapping bugs is really difficult because the error output is very vague.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.