-->
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.  [ 10 posts ] 
Author Message
 Post subject: struts-hibernate example and firebird problem
PostPosted: Thu Jan 08, 2004 12:20 pm 
Beginner
Beginner

Joined: Mon Jan 05, 2004 12:48 pm
Posts: 31
Hello-
With some difficulties but i've managed to install struts-example on Tomcat-4 and Firebird-1.0. And have a lot of questions.
What should this example show? I mean how to play with this example? I did not find any help, only readme about how to install this example. Well, I've installed it. What next? I see a text entry with Submit button and 3 links at http://localhost/eg1/Welcome.do. What should I enter? And what shall I expect after pressing submit? Really lost.
Moreover, when i press submit butoom (whatever i enter) the result is always error. Why?

root cause

net.sf.hibernate.JDBCException: Could not execute query
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1478)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1454)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1450)
at eg1.ContactList.login(ContactList.java:187)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)
at eg1.ContactList.execute(ContactList.java:82)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:509)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:536)
Caused by: org.firebirdsql.jdbc.FBSQLException: GDS Exception. Dynamic SQL Error
SQL error code = -104
Token unknown - line 1, char 12
.
at org.firebirdsql.jdbc.FBPreparedStatement.(FBPreparedStatement.java:81)
at org.firebirdsql.jdbc.FBConnection.prepareStatement(FBConnection.java:243)
at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:228)
at net.sf.hibernate.impl.BatcherImpl.prepareQueryStatement(BatcherImpl.java:61)
at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:703)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:184)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:132)
at net.sf.hibernate.loader.Loader.doList(Loader.java:949)
at net.sf.hibernate.loader.Loader.list(Loader.java:940)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:833)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1475)
... 49 more


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 09, 2004 7:39 am 
Beginner
Beginner

Joined: Mon Jan 05, 2004 12:48 pm
Posts: 31
After 2 days of investigations (don't forget i'm a complete newb!) i've found the reason of the matter.
This can be interested probably only to those who's going to work with Firebird/Interbase. The problem is in word "user". This word is a reserved word in IB/FB and should not be used in SQL queries as identifier without quotes. So, in struts-hibernate example Hibernate generates this SQL query:
Code:
select user.user_uid as user_uid, user.version as version, user.name as name, user.userName as userName from cl_users user where (user.userName='login' );

and FB complaints at the first dot - in user.user_uid.
However this query looks ok for IB/FB:
Code:
select "user".user_uid as user_uid, "user".version as version, "user".name
as name, "user".userName as userName from cl_users "user" where ("user".userName='login' );

I've checked - it works.

Advice: don't use word "user" w/o quotes in HQL quries if you work with FB/IB. In that example it was:
HQL_FIND_USER = "FROM user IN class eg.User WHERE user.userName = ?";

Can anybody add more comments?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 09, 2004 11:29 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You must be using an obsolete version of Hibernate.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 10, 2004 6:33 am 
Beginner
Beginner

Joined: Mon Jan 05, 2004 12:48 pm
Posts: 31
Not really. Hibernate 2.1.1 bundle downloaded at 17 dec 2003. And the latest version of struts-hibernate also.
With d-qouted word user in HQL query like this:
Code:
    public static String HQL_FIND_USER = "FROM \"user\" IN class eg.User WHERE \"user\".userName = ?";

instead of that was presented in example:
Code:
    public static String HQL_FIND_USER = "FROM user IN class eg.User WHERE user.userName = ?";

everywhere, the example works for me fine. The only thing that i'm still feelling lost with is that i can't figure out pretty much how to play with that example - i mean a poor explanation of its logic flow. I wish to have more elaborated intro to this example.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 10, 2004 8:14 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I am quite sure it is not 2.1.1. I expect you have an old version of hibernate2.jar that ships with struts-hibernate.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 10, 2004 9:06 am 
Beginner
Beginner

Joined: Mon Jan 05, 2004 12:48 pm
Posts: 31
I have E:\Tomcat-4.1.24\webapps\eg1\WEB-INF\lib\hibernate.jar of 889,958 bytes of the same size as hibernate2.jar from Hibernate 2.1.1 distribution. I check this 2 jars by fc - complete identity.
Is hibernate-2.1.1.zip of 14,325,050 bytes obsolete?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 10, 2004 9:16 am 
Beginner
Beginner

Joined: Mon Jan 05, 2004 12:48 pm
Posts: 31
Moreover struts-example does not contain itself hibernate2.jar at all. User should build example by ant and must mannualy proceed with all necessary configuration himself. So I point to the latest version of Hibernate 2.1.1.
my build.properties:
Code:
hibernate.jar = I:\Java\Hibernate\hibernate-2.1.1\hibernate-2.1\hibernate2.jar
hibernate.lib = I:\Java\Hibernate\hibernate-2.1.1\hibernate-2.1\lib


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 10, 2004 9:20 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Oh yeah, come to think of it, I think this does happen with the old deprecated "user in class User" syntax.

You should use the Hibernate2 style:

Code:
from User user WHERE user.userName = ?


and then it won't occur.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 10, 2004 9:45 am 
Beginner
Beginner

Joined: Mon Jan 05, 2004 12:48 pm
Posts: 31
It works! New syntax is really better - shorter and clearer. Thanks a lot to you, Gavin:))
I'll continue my hibernate studing further:))


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 10, 2004 9:48 am 
Beginner
Beginner

Joined: Mon Jan 05, 2004 12:48 pm
Posts: 31
And one more important thing - with new syntax user does not not take care about the specific dialects of the underlying DB. That's really cool!


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