-->
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.  [ 4 posts ] 
Author Message
 Post subject: help with SQL Error: 1054, SQLState: 42S22
PostPosted: Sat Feb 13, 2010 8:01 pm 
Newbie

Joined: Sat Feb 13, 2010 7:52 pm
Posts: 2
hi,

i havve a problem while execute query
i have two beans:

user
client that extends user

when i make the query asking for client, all work ok
but when i ask for user i have a Error: 1054, SQLState: 42S22

this is beacuse hibernate is trying to make a select to client table with the fields of user

Hibernate: select usuario0_.idUsuario as idUsuario11_, usuario0_.passUsuario as passUsua2_11_, usuario0_.eMail as eMail11_, usuario0_.idPerfil as idPerfil11_ from usuario usuario0_ where idUsuario='user1' and passUsuario='password'
Hibernate: select cliente0_.rutCliente as rutCliente0_, cliente0_.nomCliente as nomCliente0_, cliente0_.apePaterno as apePaterno0_, cliente0_.apeMaterno as apeMaterno0_, cliente0_.dirCliente as dirCliente0_, cliente0_.eMailCliente as eMailCli6_0_, cliente0_.idComuna as idComuna0_, cliente0_.fono1Cliente as fono8_0_, cliente0_.fono2Cliente as fono9_0_ from cliente cliente0_ where idUsuario='user1' and passUsuario='password'

if a remove the inheritance from client the query work ok

the user mapping is:

<class name="Usuario" table="usuario" lazy="false">
<id name="user" type="string" column="idUsuario"/>
<property name="password" column="passUsuario" type="string"/>
<property name="email" column="eMail" type="string"/>
<property name="perfil" column="idPerfil" type="int"/>
</class>

and the client mapping is:

<class name="Cliente" table="cliente">
<id name="rut" column="rutCliente" type="string">
<generator class="assigned"/>
</id>
<property name="nombre" type="string" column="nomCliente"/>
<property name="apPaterno" type="string" column="apePaterno"/>
<property name="apMaterno" type="string" column="apeMaterno"/>
<property name="direccion" type="string" column="dirCliente"/>
<property name="email" type="string" column="eMailCliente"/>
<property name="comuna" type="int" column="idComuna"/>
<property name="telefono1" type="string" column="fono1Cliente"/>
<property name="telefono2" type="string" column="fono2Cliente"/>
<set name="marcas" lazy="false">
<key column="rutCliente"/>
<one-to-many class="Marca"/>
</set>
</class>

can anyone say me what im doing wrong??
thanks


Top
 Profile  
 
 Post subject: Re: help with SQL Error: 1054, SQLState: 42S22
PostPosted: Sun Feb 14, 2010 5:37 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Hmmm.... I just don't get which type of inheritance strategy you are modeling here... Since your Client class is a subclass of User it is typical to map this with a <joined-subclass> or <subclass><join>.... But then you'll need a join column in the client table that references the user table...

Well, I think you should read the chapter about inheritance in the Hibernate documentation: http://docs.jboss.org/hibernate/stable/ ... tance.html


Top
 Profile  
 
 Post subject: Re: help with SQL Error: 1054, SQLState: 42S22
PostPosted: Sun Feb 14, 2010 8:18 pm 
Newbie

Joined: Sat Feb 13, 2010 7:52 pm
Posts: 2
actually im not mapping any inheritace strategy
both classes can be accesed independently and is working with the exception that when i acces the user hibernate is looking for it in two tables, the log says

Hibernate: select usuario0_.idUsuario as idUsuario11_, usuario0_.passUsuario as passUsua2_11_, usuario0_.eMail as eMail11_, usuario0_.idPerfil as idPerfil11_ from usuario usuario0_ where idUsuario='user1' and passUsuario='password'
Hibernate: select cliente0_.rutCliente as rutCliente0_, cliente0_.nomCliente as nomCliente0_, cliente0_.apePaterno as apePaterno0_, cliente0_.apeMaterno as apeMaterno0_, cliente0_.dirCliente as dirCliente0_, cliente0_.eMailCliente as eMailCli6_0_, cliente0_.idComuna as idComuna0_, cliente0_.fono1Cliente as fono8_0_, cliente0_.fono2Cliente as fono9_0_ from cliente cliente0_ where idUsuario='user1' and passUsuario='password'

the first select its ok, but the second is wrong beacuse the fields idusuario and passusuario dont exist in cliente table
if is a mapping error, can you say me how i should do it??

thanks


Top
 Profile  
 
 Post subject: Re: help with SQL Error: 1054, SQLState: 42S22
PostPosted: Mon Feb 15, 2010 2:58 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Quote:
actually im not mapping any inheritace strategy


Then, why is Client a subclass of User? That sure looks like inheritance to me.


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