-->
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.  [ 4 posts ] 
Author Message
 Post subject: How to query foregin key like a string using Criteria?
PostPosted: Wed Dec 10, 2003 1:30 am 
Regular
Regular

Joined: Wed Dec 03, 2003 9:41 pm
Posts: 87
I used Criteria to create query but Exception occur.
My java code like here:
crit.add(Expression.ilike("bourseCode", model.getBourseCode()));

and xml like here:
<many-to-one name="bourseCode" class="com.bsteel.newbase.admin.marketdata.model.BourseCodeModel" column="BOURSE_CODE"/>

when I replace Expression.ilike with Expression.eq, it works well. What the matter? How can I query the foregin key with ilike?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 10, 2003 1:32 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
eh?? ilike() doesn't seem to make sense for an association!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 10, 2003 1:34 am 
Regular
Regular

Joined: Wed Dec 03, 2003 9:41 pm
Posts: 87
Exception fragment is the following:
net.sf.hibernate.MappingException: No persister for: java.lang.String

at net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryImpl.java:338)

at net.sf.hibernate.impl.SessionImpl.getClassPersister(SessionImpl.java:2569)

at net.sf.hibernate.impl.SessionImpl.getPersister(SessionImpl.java:2576)

at net.sf.hibernate.impl.SessionImpl.getEntityIdentifierIfNotUnsaved(SessionImpl.java:2638)

at net.sf.hibernate.type.EntityType.getIdentifier(EntityType.java:66)

at net.sf.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:46)

................


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 10, 2003 2:03 am 
Regular
Regular

Joined: Wed Dec 03, 2003 9:41 pm
Posts: 87
I had done it.
I modified my code :
crit.add(Expression.ilike("bourseCode.id", model.getBourseCode()));
and it runs well.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.