-->
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.  [ 3 posts ] 
Author Message
 Post subject: Firebird + criteria: could not execute query
PostPosted: Thu Jun 16, 2005 8:14 pm 
Newbie

Joined: Thu Jun 16, 2005 8:01 pm
Posts: 14
Hi boys and girls :),

I am using Firebird 'firebirdsql-full_jdk1.4.jar' and Hibernate 3 and cannot use criteria for some strange reason.

I tried some differend way's
Quote:
List result = crit.add( Example.create(criteria) )
.list();

List result = crit.add( Expression.eq("userName","Statix") )
.list();


And every time hibernate says it cannot execute query.

This is the query (from console):
Quote:
Hibernate: select this_.USER_ID as USER1_0_, this_.USER_NAME as USER2_0_0_, this_.USER_PASSWORD as USER3_0_0_, this_.USER_GROUP_ID as USER4_0_0_ from USER this_ where (this_.USER_NAME=? and this_.USER_PASSWORD=?)


And the hibernate error is :
Quote:
Exception in thread "AWT-EventQueue-0" org.hibernate.exception.GenericJDBCException: could not execute query


A little bit lower there is an error from firebird:
Quote:
Caused by: org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544569. Dynamic SQL Error


The dynamic error is because of the criteria I guess... because without the criteria the app works fine.

Can anyone send me in the correct direction? I am struggling for some time with hibernate and learned a lot already but probably not enough :)

Any help will be appreciated

Statix


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 11:34 pm 
Beginner
Beginner

Joined: Mon Jun 13, 2005 5:52 pm
Posts: 43
What result do you get when you try to run the SQL directly (replacing question marks with dummy values)?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 17, 2005 4:00 am 
Newbie

Joined: Thu Jun 16, 2005 8:01 pm
Posts: 14
Erm... how do you mean?

Something like this?
Code:
List result = crit.add( Example.create(criteria) ).list();

into

List result = session.createSQLQuery("select userName from User").addEntity("User",User.class).list();


The last option gives me the following error
Quote:
Exception in thread "AWT-EventQueue-0" org.hibernate.exception.GenericJDBCException: could not execute query


I do not know how to solve this problem :( under here is my code

This is my user.hbm.xml
Code:
<hibernate-mapping package="com.gfs.pojo">
    <class name="User" table="USER">
        <id name="userId" column="USER_ID">
            <generator class="increment"/>
        </id>

        <property name="userName" column="USER_NAME" type="java.lang.String"  not-null="true" />
        <property name="userPassword" column="USER_PASSWORD" type="java.lang.String"  not-null="true" />

        <many-to-one name="userGroup" column="USER_GROUP_ID" class="UserGroup" />
    </class>   
</hibernate-mapping>


and my mapping:
Code:
/*
package com.gfs.pojo;

import java.io.Serializable;

public abstract class AbstractUser
    implements Serializable
{
    private int hashValue = 0;

    private java.lang.Integer userId;
    private UserGroup userGroup;
    private java.lang.String userName;
    private java.lang.String userPassword;

    public AbstractUser()
    {
    }
    public AbstractUser(java.lang.Integer userId)
    {
        this.setUserId(userId);
    }
    public java.lang.Integer getUserId()
    {
        return userId;
    }
    public void setUserId(java.lang.Integer userId)
    {
        this.hashValue = 0;
        this.userId = userId;
    }
    public UserGroup getUserGroup()
    {
        return this.userGroup;
    }
    public void setUserGroup(UserGroup userGroup)
    {
        this.userGroup = userGroup;
    }
    public java.lang.String getUserName()
    {
        return this.userName;
    }
    public void setUserName(java.lang.String userName)
    {
        this.userName = userName;
    }
    public java.lang.String getUserPassword()
    {
        return this.userPassword;
    }
    public void setUserPassword(java.lang.String userPassword)
    {
        this.userPassword = userPassword;
    }

    public boolean equals(Object rhs)
    {
        if (rhs == null)
            return false;
        if (! (rhs instanceof User))
            return false;
        User that = (User) rhs;
        if (this.getUserId() != null && that.getUserId() != null)
        {
            if (! this.getUserId().equals(that.getUserId()))
            {
                return false;
            }
        }
        return true;
    }

    public int hashCode()
    {
        if (this.hashValue == 0)
        {
            int result = 17;
            int userIdValue = this.getUserId() == null ? 0 : this.getUserId().hashCode();
            result = result * 37 + userIdValue;
            this.hashValue = result;
        }
        return this.hashValue;
    }
}



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