-->
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: Hibernate 3.0.4
PostPosted: Tue May 24, 2005 6:27 pm 
Beginner
Beginner

Joined: Sat Oct 09, 2004 2:35 pm
Posts: 43
Location: Tenerife
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0.4

Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
>

<class
name="com.apl.conad.model.Tusuarios"
table="USUARIOS"
proxy="com.apl.conad.model.Tusuarios"
dynamic-update="true"
dynamic-insert="true"
discriminator-value="null"
>

<id
name="id"
column="ID"
type="long"
length="15"
>

<generator class="sequence">
<param name="sequence">GENIDUSUARIOS</param>
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Tusuarios.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<version
name="version"
column="VERSION"
type="long"
access="property"
unsaved-value="undefined"
/>

<property
name="usuarioId"
>

<column
name="IDUSUARIO"
sql-type="VARCHAR(8)"
/>

</property>

<property
name="password"
>

<column
name="PW"
sql-type="VARCHAR(20)"
/>

</property>

<property
name="nombreCompleto"
>

<column
name="NOMBRECOMPLETO"
sql-type="VARCHAR(50)"
/>

</property>

<property
name="email"
>

<column
name="EMAIL"
sql-type="VARCHAR(60)"
/>

</property>

<property
name="impresora"
>

<column
name="IMPRESORA"
sql-type="VARCHAR(30)"
/>

</property>

<property
name="fuenteImpresora"
>

<column
name="FUENTEIMPRESORA"
sql-type="VARCHAR(30)"
/>

</property>

<property
name="bloqueo"
>

<column
name="BLOQUEO"
sql-type="CHAR"
/>

</property>

<property
name="consultasFacturas"
>

<column
name="CONSULTASFACTURAS"
sql-type="CHAR"
/>

</property>

<property
name="consultasCobros"
>

<column
name="CONSULTASCOBROS"
sql-type="CHAR"
/>

</property>

<property
name="borrarExpediente"
>

<column
name="BORRAREXPEDIENTE"
sql-type="CHAR"
/>

</property>

<property
name="mantenimientos"
>

<column
name="MANTENIMIENTOS"
sql-type="CHAR"
/>

</property>

<property
name="administrador"
>

<column
name="ADMINISTRADOR"
sql-type="CHAR"
/>

</property>

<property
name="locale"
>

<column
name="LOCALE"
sql-type="VARCHAR(5)"
/>

</property>

<property
name="auditInfo"
type="com.apl.conad.persistence.audit.AuditInfoType"
>

<column
name="CREADO_POR"
sql-type="VARCHAR(30)"
/>

<column
name="CREADO_FECHA"
sql-type="TIMESTAMP"
/>

<column
name="EDITADO_POR"
sql-type="VARCHAR(30)"
/>

<column
name="EDITADO_FECHA"
sql-type="TIMESTAMP"
/>

</property>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Tusuarios.xml
containing the additional properties and place it in your merge dir.
-->

</class>

<query name="usuFindAdministrador"><![CDATA[
SELECT usuarios.administrador FROM com.apl.conad.model.Tusuarios AS usuarios WHERE usuarios.usuarioId = :usuario AND usuarios.password = :password ORDER BY usuarios.usuarioId
]]></query>
<query name="usuFindId2Row"><![CDATA[
FROM com.apl.conad.model.Tusuarios AS usuarios WHERE usuarios.usuarioId = :usuarioId ORDER BY usuarios.usuarioId
]]></query>
<query name="usuFindFirstRow"><![CDATA[
FROM com.apl.conad.model.Tusuarios AS usuarios WHERE usuarios.usuarioId >= :usuarioId ORDER BY usuarios.usuarioId
]]></query>
<query name="usuFindLastRow"><![CDATA[
FROM com.apl.conad.model.Tusuarios AS usuarios WHERE usuarios.usuarioId <= :usuarioId ORDER BY usuarios.usuarioId DESC
]]></query>
<query name="usuFindNextRow"><![CDATA[
FROM com.apl.conad.model.Tusuarios AS usuarios WHERE usuarios.usuarioId > :usuarioId ORDER BY usuarios.usuarioId
]]></query>
<query name="usuFindPreviousRow"><![CDATA[
FROM com.apl.conad.model.Tusuarios AS usuarios WHERE usuarios.usuarioId < :usuarioId ORDER BY usuarios.usuarioId DESC
]]></query>
<query name="usuFindNumeroDesdeHasta"><![CDATA[
SELECT count(*) FROM com.apl.conad.model.Tusuarios AS usuarios WHERE (usuarios.usuarioId >= :usuarioDesdeId AND usuarios.usuarioId <= :usuarioHastaId) AND (usuarios.nombreCompleto >= :nombreDesde AND usuarios.nombreCompleto <= :nombreHasta)
]]></query>
<query name="usuFindDesdeHastaOrdenadoPk"><![CDATA[
SELECT usuarios.usuarioId, usuarios.password, usuarios.nombreCompleto, usuarios.email, usuarios.bloqueo, usuarios.consultasFacturas, usuarios.consultasCobros, usuarios.borrarExpediente, usuarios.mantenimientos, usuarios.administrador, usuarios.locale FROM com.apl.conad.model.Tusuarios AS usuarios WHERE (usuarios.usuarioId >= :usuarioDesdeId AND usuarios.usuarioId <= :usuarioHastaId) AND (usuarios.nombreCompleto >= :nombreDesde AND usuarios.nombreCompleto <= :nombreHasta) ORDER BY usuarios.usuarioId, usuarios.nombreCompleto
]]></query>
<query name="usuFindDesdeHastaOrdenadoNombre"><![CDATA[
SELECT usuarios.usuarioId, usuarios.password, usuarios.nombreCompleto, usuarios.email, usuarios.bloqueo, usuarios.consultasFacturas, usuarios.consultasCobros, usuarios.borrarExpediente, usuarios.mantenimientos, usuarios.administrador, usuarios.locale FROM com.apl.conad.model.Tusuarios AS usuarios WHERE (usuarios.usuarioId >= :usuarioDesdeId AND usuarios.usuarioId <= :usuarioHastaId) AND (usuarios.nombreCompleto >= :nombreDesde AND usuarios.nombreCompleto <= :nombreHasta) ORDER BY usuarios.nombreCompleto, usuarios.usuarioId
]]></query>
<query name="usuFindNumeroInCodigo"><![CDATA[
SELECT count(*) FROM com.apl.conad.model.Tusuarios AS usuarios WHERE usuarios.usuarioId LIKE :usuarioId
]]></query>
<query name="usuFindInCodigo"><![CDATA[
SELECT usuarios.usuarioId, usuarios.password, usuarios.nombreCompleto FROM com.apl.conad.model.Tusuarios AS usuarios WHERE usuarios.usuarioId LIKE :usuarioId ORDER BY usuarios.usuarioId, usuarios.nombreCompleto
]]></query>
<query name="usuFindNumeroInCodigoUpper"><![CDATA[
SELECT count(*) FROM com.apl.conad.model.Tusuarios AS usuarios WHERE UPPER(usuarios.usuarioId) LIKE UPPER(:usuarioId)
]]></query>
<query name="usuFindInCodigoUpper"><![CDATA[
SELECT usuarios.usuarioId, usuarios.password, usuarios.nombreCompleto FROM com.apl.conad.model.Tusuarios AS usuarios WHERE UPPER(usuarios.usuarioId) LIKE UPPER(:usuarioId) ORDER BY usuarios.usuarioId, usuarios.nombreCompleto
]]></query>
<query name="usuFindNumeroInName"><![CDATA[
SELECT count(*) FROM com.apl.conad.model.Tusuarios AS usuarios WHERE usuarios.nombreCompleto LIKE :nombreCompleto
]]></query>
<query name="usuFindInName"><![CDATA[
SELECT usuarios.usuarioId, usuarios.password, usuarios.nombreCompleto FROM com.apl.conad.model.Tusuarios AS usuarios WHERE usuarios.nombreCompleto LIKE :nombreCompleto ORDER BY usuarios.usuarioId, usuarios.nombreCompleto
]]></query>
<query name="usuFindNumeroInNameUpper"><![CDATA[
SELECT count(*) FROM com.apl.conad.model.Tusuarios AS usuarios WHERE UPPER(usuarios.nombreCompleto) LIKE UPPER(:nombreCompleto)
]]></query>
<query name="usuFindInNameUpper"><![CDATA[
SELECT usuarios.usuarioId, usuarios.password, usuarios.nombreCompleto FROM com.apl.conad.model.Tusuarios AS usuarios WHERE UPPER(usuarios.nombreCompleto) LIKE UPPER(:nombreCompleto) ORDER BY usuarios.usuarioId, usuarios.nombreCompleto
]]></query>
<query name="usuFindNumeroAll"><![CDATA[
SELECT count(*) FROM com.apl.conad.model.Tusuarios AS usuarios
]]></query>
<query name="usuFindAll"><![CDATA[
FROM com.apl.conad.model.Tusuarios AS usuarios ORDER BY usuarios.usuarioId, usuarios.nombreCompleto
]]></query>
<query name="usuFindAllNombre"><![CDATA[
FROM com.apl.conad.model.Tusuarios AS usuarios ORDER BY usuarios.nombreCompleto, usuarios.usuarioId
]]></query>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
CODE EXCERPT from com.apl.conad.dao.TusuariosDAO where appears the line that originates the problem:
if (opcion == false) {
query = currentSession().getNamedQuery("usuFindInCodigo");
} else {
query = currentSession().getNamedQuery("usuFindInCodigoUpper");
}

query.setString(STR_USUARIO_ID, usuarioId);

if ((numeroLineas != 0) && (numeroPaginas != 0)) {
query.setMaxResults(numeroLineas);
query.setFirstResult(numeroLineas * (numeroPaginas - 1));
}

query.setLockMode(STR_TUSUARIOS, LockMode.NONE);

currentSession().setFlushMode(FlushMode.NEVER);

LINE 1438
List queryList = query.list();


Full stack trace of any exception that occurs:
java.lang.IllegalArgumentException: alias not found: Tusuarios
at org.hibernate.loader.hql.QueryLoader.applyLocks(QueryLoader.java:319)
at org.hibernate.loader.Loader.preprocessSQL(Loader.java:182)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1146)
at org.hibernate.loader.Loader.doQuery(Loader.java:383)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:211)
at org.hibernate.loader.Loader.doList(Loader.java:1588)
at org.hibernate.loader.Loader.list(Loader.java:1571)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at com.apl.conad.dao.TusuariosDAO.findInCodigo(TusuariosDAO.java:1438)
at com.apl.conad.dao.TusuariosDAO.findInCodigo(TusuariosDAO.java:1341)
at com.apl.conad.exec.Menus.loadUsuarios(Menus.java:308)
at com.apl.conad.exec.Menus.inicializo(Menus.java:167)
at com.apl.conad.exec.Menus.<init>(Menus.java:163)
at com.apl.conad.exec.Conad.btnEntrarActionPerformed(Conad.java:1060)
at com.apl.conad.exec.Conad.access$200(Conad.java:63)
at com.apl.conad.exec.Conad$3.actionPerformed(Conad.java:480)


Name and version of the database you are using:
Firebird 1.5

The generated SQL (show_sql=true):
FROM com.apl.conad.model.TusuariosMenus AS usuariosMenus WHERE usuariosMenus.usuarioId = :usuarioId ORDER BY usuariosMenus.usuarioId, usuariosMenus.menuId

Debug level Hibernate log excerpt:
none


As I installed recent 3.0.4 release, this piece of code suddenly began to give me problems.
Everything worked perfectly in previous releases. In fact, if I reinstall release 3.0.3 everything starts to work again...
What so important has changed in release 3.0.4?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 8:28 am 
Beginner
Beginner

Joined: Sat Oct 09, 2004 2:35 pm
Posts: 43
Location: Tenerife
Same problem with 3.0.5 release


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 8:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Well, I'm not sure because you don't bother to tell us what STR_TUSUARIOS is, but it looks like you are trying to set a lockmode for a nonexistent alias ("Tusuarios" instead of "usuarios"), and Hibernate is now being a bit more careful to validate this stuff.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 11:39 am 
Beginner
Beginner

Joined: Sat Oct 09, 2004 2:35 pm
Posts: 43
Location: Tenerife
2 things:
First, you were right Gavin, STR_TUSUARIOS was Tusuarios.
Second, I change it to usuarios and still get the same error but only with this table, some others suffering the same problem have started to work again...


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 11:43 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
It will work when the alias you pass to setLockMode() is the same as the alias used in the HQL query.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 3:53 pm 
Beginner
Beginner

Joined: Sat Oct 09, 2004 2:35 pm
Posts: 43
Location: Tenerife
As you can see from my previous posted mapping, the query is usuFindInCodigo and the alias used there is "usuarios": query.setLockMode("usuarios", LockMode.NONE) still gives me the same error as before...


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 5:34 pm 
Beginner
Beginner

Joined: Sat Oct 09, 2004 2:35 pm
Posts: 43
Location: Tenerife
Perhaps I am missing something but this query:

Code:
SELECT usuarios.usuarioId, usuarios.password, usuarios.nombreCompleto FROM com.apl.conad.model.Tusuarios AS usuarios WHERE usuarios.usuarioId LIKE :usuarioId ORDER BY usuarios.usuarioId, usuarios.nombreCompleto


does not work with
Code:
setLockMode("usuarios", LockMode.NONE);


BUT this one:

Code:
FROM com.apl.conad.model.Tusuarios AS usuarios WHERE usuarios.usuarioId LIKE :usuarioId ORDER BY usuarios.usuarioId, usuarios.nombreCompleto


really does.
An all this worked perfectly with releases 3.0.3 and previous
any suggestions?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 8:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
So, use your debugger to find the problem.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 8:43 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Oh, duh. setLockMode() only applies to returned entities, not projected "stuff".

Why on earth would anyone ever want to use LockMode.UPGRADE for data they aren't updating???


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 9:52 pm 
Beginner
Beginner

Joined: Sat Oct 09, 2004 2:35 pm
Posts: 43
Location: Tenerife
Ok, you give me a highway and I use my village road. Sorry, it's life...

Anyway, the returned message should be a little more explicit: "Trying to Lock an unlockable entity" or something like that, because the message received "alias not found" has kept me looking at MY code trying to find out why on earth the stated alias was not found...

What I did not understand is that everything worked fine in release 3.0.3 and previous...

Having a look at your QueryLoader code I see the throw exception added in release 3.0.4...
That's why before everything worked for me: LockMode was WRONG but no message was returned. So, if you look at it more slowly, trying to LockMode.NONE something that is not HibernateLockable is not so WRONG because you are doing something that Hibernate has already done: The message should be none.

Thanks to Gavin for the interest given to this.


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.