-->
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.  [ 6 posts ] 
Author Message
 Post subject: how to use "Criteria" to compare int(less or above
PostPosted: Thu Sep 29, 2005 1:52 am 
Newbie

Joined: Sun Aug 14, 2005 9:34 pm
Posts: 5
hi. when i use the direct sql in hibernate+appfuse+postgres.
i came across a problem of showing chinese.
i could print out the chinese in the back, but got no result.
at the same time, i tried the sql print out in pgadmin, and got the result i wanted.

so i turned to another way to use Criteria.
i noticed that there about method .ls &. lt.. what's this two method?

i wanted to query some file like file_size<64
so how to write in Criteria?

criteria.add(Expression.ls("file_size",String.valueOf(64)));

i tried the sentence above, and got a error.

how to compare int?

millions of thanks.


Top
 Profile  
 
 Post subject: Re: how to use "Criteria" to compare int(less or a
PostPosted: Thu Sep 29, 2005 2:12 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
ipis wrote:
i tried the sentence above, and got a error.


stacktrace?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 29, 2005 2:19 am 
Newbie

Joined: Sun Aug 14, 2005 9:34 pm
Posts: 5
the code is below,
--------------------------------------------
Criteria criteria = getSession().createCriteria(File.class);
Criterion c =Expression.or(Expression.like("author", "%"+author+"%"), Expression.like("file_name", "%"+file_name+"%"));
criteria.add( c);
criteria.add(Expression.eq("content_type_name",content_type_name));
criteria.add(Expression.lt("file_size",String.valueOf(file_size)));
---------------------------------------------

am i use the wrong method?
i set a point to check it, and it errored in the last sentence. when i changed the "lt" to "eq", error stayed the same.

any advice?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 29, 2005 2:31 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
ipis wrote:
i noticed that there about method .ls &. lt.. what's this two method

http://sun.calstatela.edu/~cysun/documentation/hibernate/api/org/hibernate/criterion/Restrictions.html#lt(java.lang.String,%20java.lang.Object)

ipis wrote:
i set a point to check it, and it errored in the last sentence. any advice?

my advice is to provide a stacktrace


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 29, 2005 3:46 am 
Newbie

Joined: Sun Aug 14, 2005 9:34 pm
Posts: 5
thanks for you help.
by the way. i don't understand what you mean.
could you give me some example?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 29, 2005 4:00 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
Stacktraces look like this, and they will appear in your log ;-)

Code:
D:\workspace-hibtools3\Demo\build.xml:61: The <hibernatetool> type doesn't support the nested "hbm2jsf" element.
   at org.apache.tools.ant.IntrospectionHelper.throwNotSupported(IntrospectionHelper.java:463)
   at org.apache.tools.ant.UnknownElement.handleChildren(UnknownElement.java:329)
   at org.apache.tools.ant.UnknownElement.configure(UnknownElement.java:182)
   at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:158)
   at org.apache.tools.ant.Task.perform(Task.java:363)
   at org.apache.tools.ant.Target.execute(Target.java:341)
   at org.apache.tools.ant.Target.performTasks(Target.java:369)
   at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
   at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
   at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
   at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
   at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:416)
   at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:138)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.