-->
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: A question about distinct
PostPosted: Tue Sep 07, 2004 6:51 am 
Beginner
Beginner

Joined: Thu Jul 22, 2004 4:32 am
Posts: 31
String hql =
"select departmentPO from EmployePO as employePO join employePO.departmentPO as departmentPO "+
"where employePO.employeName like '%Jason%'"+
"order by departmentPO.deptId";

department table in database:
deptId deptName
d001 Java Team
d002 .net Team

employe table in database:
employeId employeName deptId
e001 Jason Lian d001
e002 Jason Tang d001
e003 Jason Yu d002

there are two results of query.list(): d001 , d001 and d002

how can I get a distinct results like d001 and d002?

select but when I use "select distinct departmentPO......",Hibernate reports a error:
Caused by: java.sql.SQLException: The text, ntext, or image data type cannot be selected as DISTINCT. Severity 16, State 3, Procedure 'JAVASERVER2 null', Line 1
at weblogic.jdbc.mssqlserver4.TdsStatement.processWarning(TdsStatement.java:1193)
at weblogic.jdbc.mssqlserver4.TdsStatement.parseMsWarning(TdsStatement.java:1104)
at weblogic.jdbc.mssqlserver4.TdsStatement.getMoreResults(TdsStatement.java:771)
at weblogic.jdbc.mssqlserver4.TdsStatement.execute(TdsStatement.java:210)
at weblogic.jdbc.mssqlserver4.TdsStatement.executeQuery(TdsStatement.java:54)
at weblogic.jdbc.mssqlserver4.TdsStatement.executeQuery(TdsStatement.java:1439)
at weblogic.jdbc.wrapper.PreparedStatement.executeQuery(PreparedStatement.java:80)
at weblogic.jdbc.rmi.internal.PreparedStatementImpl_weblogic_jdbc_wrapper_PreparedStatement_weblogic_jdbc_mssqlserver4_TdsPreparedStatement.executeQuery(Unknown Source)
at weblogic.jdbc.rmi.internal.PreparedStatementImpl_weblogic_jdbc_wrapper_PreparedStatement_weblogic_jdbc_mssqlserver4_TdsPreparedStatement_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:407)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:356)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:123)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:351)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:178)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:151)

I don't want to use like new HashSet(query.list()),because I want to sort by deptId.

I also don't want to use like
ArrayList result = new ArrayList();
for (Iterator it = query.list().iterator();it.hasNext();) {
Object object = it.next();
if (!result.contains(object)) {
result.add(object);
}
}
return result;
because I want to count the total number of query result

thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 07, 2004 7:10 am 
Beginner
Beginner

Joined: Thu Jul 22, 2004 4:32 am
Posts: 31
or I should write a new hql?
but tell me how,please.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 07, 2004 11:56 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
This is a sqlserver limitation, try to remove text ntext and image comumn types

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 07, 2004 8:51 pm 
Beginner
Beginner

Joined: Thu Jul 22, 2004 4:32 am
Posts: 31
Did you means I can't do it with sqlserver text type?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 07, 2004 8:54 pm 
Beginner
Beginner

Joined: Thu Jul 22, 2004 4:32 am
Posts: 31
How should I write a new hql to reach the same destination?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 08, 2004 5:31 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You can't, this is a SQLServer limitation

_________________
Emmanuel


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.