-->
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.  [ 2 posts ] 
Author Message
 Post subject: Select sur un champ ne marche pas , sur l'objet marche
PostPosted: Fri Sep 22, 2006 5:25 am 
Newbie

Joined: Tue Jul 25, 2006 8:59 am
Posts: 18
Hibernate version:2.0

Bonjour,

J'ai un problème pour recuperer la valeur d'un champ avec createSQLQuery.

Si je veux recuperer l'objet , il n'y a pas de problème , mais si je veux récupérer un champ : j'ai cette erreur

Code:
Caused by: java.sql.SQLException: Nom de colonne non valide
   at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
   at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
   at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
   at oracle.jdbc.driver.OracleStatement.get_column_index(OracleStatement.java:5971)
   at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:1527)
   at oracle.jdbc.driver.OracleResultSet.getInt(OracleResultSet.java:1528)
   at net.sf.hibernate.type.IntegerType.get(IntegerType.java:18)


voici ma requete sur un champ :
Code:
Integer id = (Integer) session.createSQLQuery("SELECT {g}.Id_Labo FROM Grossiste {g} where {g}.Id_Grossiste="+ diff.getIdGrossiste()+ " ", "g",org.ultimania.model.Grossiste.class).uniqueResult();


et mon mapping
Code:
<class
    name="org.ultimania.model.Grossiste"
    table="GROSSISTE"
    lazy="true"
>

    <id
        name="idGrossiste"
        type="java.lang.Integer"
        column="ID_GROSSISTE"
    >
   
        <generator class="assigned" />
    </id>

  <property
        name="idLabo"
        type="java.lang.Integer"
        column="ID_LABO"
        length="22"
    />


j'ai même essayer avec
Code:
access="field"


cela ne marche pas
Code:
java.sql.SQLException: Nom de colonne non valide


pourtant si je fait une requete pour avoir l'objet cela marche...


Top
 Profile  
 
 Post subject: probleme resolu
PostPosted: Fri Sep 22, 2006 9:23 am 
Newbie

Joined: Tue Jul 25, 2006 8:59 am
Posts: 18
J'ai résolu mon problème , il fallait faire :

idLabo = ( (Long) session.createQuery("SELECT gr.idLabo FROM Grossiste gr where id_grossiste="+ diff.getIdGrossiste() + " ").uniqueResult());


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.