-->
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.  [ 8 posts ] 
Author Message
 Post subject: SQL error when retrieving an object.
PostPosted: Sun Jan 09, 2005 10:12 pm 
Beginner
Beginner

Joined: Tue May 11, 2004 10:40 am
Posts: 37
Location: Belgium
Hibernate version: version 2.1.7

I have a class Number thas has several subclasses.
Storing a number gives no problem, but when I execute the following:

collection = session.find("FROM number");

I get the following error:

Caused by: java.sql.SQLException: Expected to find "FROM" instead found "NUMBER_3_" at position 49.




Code:
        <joined-subclass
            name="datastructures.syntaxtree.Number"
            table="NUMBER">
            <key column="NUMBER_ID"/>
            <joined-subclass           
                name="datastructures.syntaxtree.DoubleNbr"
                table="DOUBLE_NBR">
                <key column="DOUBLE_NBR_ID"/>   
                <property  name="value"  column="VALUE"  type="double"/>     
            </joined-subclass>           
            <joined-subclass
                name="datastructures.syntaxtree.IntNbr"
                table="INT_NBR">
                <key column="INT_NBR_ID"/>
                <property  name="value"  column="VALUE"  type="int"/>       
            </joined-subclass>           
            <joined-subclass
                name="datastructures.syntaxtree.FloatNbr"
                table="FLOAT_NBR">
                <key column="FLOAT_NBR_ID"/>   
                <property  name="value"  column="VALUE"  type="float"/>     
            </joined-subclass>           
            <joined-subclass
                name="datastructures.syntaxtree.LongNbr"
                table="LONG_NBR">
                <key column="LONG_NBR_ID"/> 
                <property  name="value"  column="VALUE"  type="long"/>       
            </joined-subclass>                                               
                       
        </joined-subclass>






Code:
Hibernate: insert into SYNTAX_TREE_COMPONENT (NAME, SYNTAX_COMPONENT_ID) values (?, ?)
Hibernate: insert into TERM (TERM_ID) values (?)
Hibernate: insert into NUMBER (NUMBER_ID) values (?)
Hibernate: insert into INT_NBR (VALUE, INT_NBR_ID) values (?, ?)
Hibernate: insert into SYNTAX_TREE_COMPONENT (NAME, SYNTAX_COMPONENT_ID) values (?, ?)
Hibernate: insert into TERM (TERM_ID) values (?)
Hibernate: insert into NUMBER (NUMBER_ID) values (?)
Hibernate: insert into INT_NBR (VALUE, INT_NBR_ID) values (?, ?)
Hibernate: insert into SYNTAX_TREE_COMPONENT (NAME, SYNTAX_COMPONENT_ID) values (?, ?)
Hibernate: insert into OPERATION (OPERATOR_TYPE, OPERATION_ID) values (?, ?)
Hibernate: insert into COMPARISON_OP (LEFT_TERM_ID, RIGHT_TERM_ID, COMPARISON_OP_ID) values (?, ?, ?)
Hibernate: insert into SYNTAX_TREE_COMPONENT (NAME, SYNTAX_COMPONENT_ID) values (?, ?)
Hibernate: insert into RULE (ACTIVE, DESCRIPTION, SCOPE_TYPE, RULE_ID) values (?, ?, ?, ?)
Hibernate: insert into CONDITIONAL_RULE (OPERATION_ID, CONDITIONAL_RULE_ID) values (?, ?)
Hibernate: select number.NUMBER_ID as SYNTAX_C1_, case when number_3_.DOUBLE_NBR_ID is not null then 1 when number_4_.INT_NBR_ID is not null then 2 when number_5_.FLOAT_NBR_ID is not null then 3 when number_6_.LONG_NBR_ID is not null then 4 when number.NUMBER_ID is not null then 0 end as clazz_, number_2_.NAME as NAME0_, number_3_.VALUE as VALUE16_, number_4_.VALUE as VALUE17_, number_5_.VALUE as VALUE18_, number_6_.VALUE as VALUE19_ from NUMBER number inner join TERM number_1_ on number.NUMBER_ID=number_1_.TERM_ID inner join SYNTAX_TREE_COMPONENT number_2_ on number.NUMBER_ID=number_2_.SYNTAX_COMPONENT_ID left outer join DOUBLE_NBR number_3_ on number.NUMBER_ID=number_3_.DOUBLE_NBR_ID left outer join INT_NBR number_4_ on number.NUMBER_ID=number_4_.INT_NBR_ID left outer join FLOAT_NBR number_5_ on number.NUMBER_ID=number_5_.FLOAT_NBR_ID left outer join LONG_NBR number_6_ on number.NUMBER_ID=number_6_.LONG_NBR_ID
02:53:15,828  WARN JDBCExceptionReporter:57 - SQL Error: 10006, SQLState: ZB005
02:53:15,828 ERROR JDBCExceptionReporter:58 - Expected to find "FROM" instead found "NUMBER_3_" at position 49.
02:53:15,828  WARN JDBCExceptionReporter:57 - SQL Error: 10006, SQLState: ZB005
02:53:15,859 ERROR JDBCExceptionReporter:58 - Expected to find "FROM" instead found "NUMBER_3_" at position 49.
net.sf.hibernate.exception.GenericJDBCException: Could not execute query
   at net.sf.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:81)
   at net.sf.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70)
   at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:30)
   at net.sf.hibernate.impl.SessionImpl.convert(SessionImpl.java:4110)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1556)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1530)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1522)
   at servicesimpl.RuleManagerImpl.retrieveAllRules(RuleManagerImpl.java:182)
   at servicesimpl.RuleManagerImpl.main(RuleManagerImpl.java:239)
Caused by: java.sql.SQLException: Expected to find "FROM" instead found "NUMBER_3_" at position 49.
   at com.pointbase.net.netJDBCPrimitives.handleResponse(Unknown Source)
   at com.pointbase.net.netJDBCPrimitives.handleJDBCObjectResponse(Unknown Source)
   at com.pointbase.net.netJDBCConnection.prepareStatement(Unknown Source)
   at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:260)
   at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:235)
   at net.sf.hibernate.impl.BatcherImpl.prepareQueryStatement(BatcherImpl.java:66)
   at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:779)
   at net.sf.hibernate.loader.Loader.doQuery(Loader.java:265)
   at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
   at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
   at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
   at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1553)
   ... 4 more
java.lang.NullPointerException
   at servicesimpl.RuleManagerImpl.main(RuleManagerImpl.java:240)




select number.NUMBER_ID as SYNTAX_C1_, case when number_3_.DOUBLE_NBR_ID is not null then 1 when number_4_.INT_NBR_ID is not null then 2 when number_5_.FLOAT_NBR_ID is not null then 3 when number_6_.LONG_NBR_ID is not null then 4 when number.NUMBER_ID is not null then 0 end as clazz_, number_2_.NAME as NAME0_, number_3_.VALUE as VALUE16_, number_4_.VALUE as VALUE17_, number_5_.VALUE as VALUE18_, number_6_.VALUE as VALUE19_ from NUMBER number inner join TERM number_1_ on number.NUMBER_ID=number_1_.TERM_ID inner join SYNTAX_TREE_COMPONENT number_2_ on number.NUMBER_ID=number_2_.SYNTAX_COMPONENT_ID left outer join DOUBLE_NBR number_3_ on number.NUMBER_ID=number_3_.DOUBLE_NBR_ID left outer join INT_NBR number_4_ on number.NUMBER_ID=number_4_.INT_NBR_ID left outer join FLOAT_NBR number_5_ on number.NUMBER_ID=number_5_.FLOAT_NBR_ID left outer join LONG_NBR number_6_ on number.NUMBER_ID=number_6_.LONG_NBR_ID


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 10, 2005 9:25 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
try:
Code:
collection = session.find("FROM Number");


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 10, 2005 9:57 am 
Beginner
Beginner

Joined: Tue May 11, 2004 10:40 am
Posts: 37
Location: Belgium
That's what I do. I just mistyped. It is still that error.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 10, 2005 10:05 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Does you database support 'case..when' synatax? Are you using the correct dialect?

I am not familiar with pointbase.

What happens when you execute the query:
Code:
select number.NUMBER_ID as SYNTAX_C1_, case when number_3_.DOUBLE_NBR_ID is not null then 1 when number_4_.INT_NBR_ID is not null then 2 when number_5_.FLOAT_NBR_ID is not null then 3 when number_6_.LONG_NBR_ID is not null then 4 when number.NUMBER_ID is not null then 0 end as clazz_, number_2_.NAME as NAME0_, number_3_.VALUE as VALUE16_, number_4_.VALUE as VALUE17_, number_5_.VALUE as VALUE18_, number_6_.VALUE as VALUE19_ from NUMBER number inner join TERM number_1_ on number.NUMBER_ID=number_1_.TERM_ID inner join SYNTAX_TREE_COMPONENT number_2_ on number.NUMBER_ID=number_2_.SYNTAX_COMPONENT_ID left outer join DOUBLE_NBR number_3_ on number.NUMBER_ID=number_3_.DOUBLE_NBR_ID left outer join INT_NBR number_4_ on number.NUMBER_ID=number_4_.INT_NBR_ID left outer join FLOAT_NBR number_5_ on number.NUMBER_ID=number_5_.FLOAT_NBR_ID left outer join LONG_NBR number_6_ on number.NUMBER_ID=number_6_.LONG_NBR_ID

directly. Do you get the same error?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 10, 2005 10:52 am 
Beginner
Beginner

Joined: Tue May 11, 2004 10:40 am
Posts: 37
Location: Belgium
Thanks for your reply!

Yes.
I get the same error when I put the query directly in pointbase.
Is it possible that pointbase the cause is of the fault and not my mapping files?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 10, 2005 10:56 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Most likely pointbase does not support some syntax Hibernate requires (most likely case when). Check that with your database docs.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 10, 2005 12:12 pm 
Beginner
Beginner

Joined: Tue May 11, 2004 10:40 am
Posts: 37
Location: Belgium
I found that pointbase (PointBase Server Version: 4.8RE) doesn't support 'case...when' statements at the moment, but words are reserved for future releases.

Is there a possible solution to solve this problem by means of hibernate?
Can we can get round this problem?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 11, 2005 6:13 am 
Beginner
Beginner

Joined: Tue May 11, 2004 10:40 am
Posts: 37
Location: Belgium
To solve my problem, I used the MySQL database instead of the Pointbase database. Another possibility was to override certain methods of the pointbase dialect, but because of lack of time I have not done that.

This might help:
http://www.hibernate.org/hib_docs/api/n ... alect.html


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