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.  [ 36 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Are literals ok in hibernate queries?
PostPosted: Wed Jul 19, 2006 12:54 pm 
Newbie

Joined: Wed Jul 19, 2006 12:50 pm
Posts: 18
I am getting an error on this query, but no detail in the error.

<query name="serviceContinuityApplications">
<![CDATA[
from DropDownValue d

where d.dropDownId = 26
]]>
</query>


Is there a property that can be turned on in hibernate config that can give more detail to errors?

Also, can a litteral be used (26) in a hibernate query?

Thanks, in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 19, 2006 3:32 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
don't you need single quotes?

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 19, 2006 3:38 pm 
Newbie

Joined: Wed Jul 19, 2006 12:50 pm
Posts: 18
It is a BIGINT field, not a char or varchar field so that is why I don not have quotes around the 26


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 19, 2006 3:49 pm 
Newbie

Joined: Fri Jun 30, 2006 5:30 pm
Posts: 13
Can you post the stack trace/error message, and your java code?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 19, 2006 4:07 pm 
Newbie

Joined: Wed Jul 19, 2006 12:50 pm
Posts: 18
The stack trace is giving an error on the query after the one in question, so it is not helpful. Here is the bean code:

public class DropDownValue {
private long dropDownValueId;
private long dropDownId;
private String value;
private String label;

/**
* @return Returns the dropDownId.
*/
public long getDropDownId() {
return dropDownId;
}
/**
* @param dropDownId The dropDownId to set.
*/
public void setDropDownId(long dropDownId) {
this.dropDownId = dropDownId;
}
/**
* @return Returns the dropDownValueId.
*/
public long getDropDownValueId() {
return dropDownValueId;
}
/**
* @param dropDownValueId The dropDownValueId to set.
*/
public void setDropDownValueId(long dropDownValueId) {
this.dropDownValueId = dropDownValueId;
}
/**
* @return Returns the label.
*/
public String getLabel() {
return label;
}
/**
* @param label The label to set.
*/
public void setLabel(String label) {
this.label = label;
}
/**
* @return Returns the value.
*/
public String getValue() {
return value;
}
/**
* @param value The value to set.
*/
public void setValue(String value) {
this.value = value;
}
}

This is what I have in the delegate class:

public static List getApplications() throws HibernateException, Exception {
List itAreas = null;

Session session = getSession();

itAreas = session.getNamedQuery("serviceContinuityApplications").list();

session.close();

return itAreas;

}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 19, 2006 4:09 pm 
Newbie

Joined: Wed Jul 19, 2006 12:50 pm
Posts: 18
This is the hbm:

<?xml version="1.0"?>
<!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.ibm.ea.smc.console.authorization.DropDownValue"
table="DROP_DOWN_VALUE" lazy="true">

<id name="dropDownValueId" type="long" column="DROP_DOWN_VALUE_ID">
<generator class="increment" />
</id>
<property name="dropDownId" type="long" column="DROP_DOWN_ID"
not-null="true" />
<property name="value" type="string" column="VALUE"
length="64" not-null="true" />
<property name="label" type="string" column="LABEL" length="64"
not-null="true" />

</class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 19, 2006 5:03 pm 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
do you have a package property in <hibernate-mapping> in the hbm file where the query is?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 19, 2006 5:28 pm 
Newbie

Joined: Wed Jul 19, 2006 12:50 pm
Posts: 18
I have this in an hql file, but there is no package tag:

<query name="serviceContinuityApplications">
<![CDATA[
from DropDownValue d

where d.dropDownId = 26

]]>
</query>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 20, 2006 12:51 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
without any error description e.g. the stacktrace it is hard to help

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 20, 2006 4:13 am 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
try with:
Code:
<query name="serviceContinuityApplications">
<![CDATA[
from com.ibm.ea.smc.console.authorization.DropDownValue d
where d.dropDownId = 26
]]>
</query>


Top
 Profile  
 
 Post subject: Stack Trace
PostPosted: Thu Jul 20, 2006 11:20 am 
Newbie

Joined: Wed Jul 19, 2006 12:50 pm
Posts: 18
Here is the stack trace (rolesByRemoteUser is the first query in the hql file. If I comment out my query and the mapping in hibernate config the error goes away):

exception

javax.servlet.ServletException: Named query not known: rolesByRemoteUser
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

org.hibernate.MappingException: Named query not known: rolesByRemoteUser
org.hibernate.impl.AbstractSessionImpl.getNamedQuery(AbstractSessionImpl.java:71)
org.hibernate.impl.SessionImpl.getNamedQuery(SessionImpl.java:1245)
com.ibm.ea.smc.console.authorization.AuthorizationDelegate.setRoles(AuthorizationDelegate.java:46)
com.ibm.ea.smc.framework.common.UserContainer.setAccessLevel(UserContainer.java:38)
com.ibm.ea.smc.framework.common.ActionBase.loadUser(ActionBase.java:113)
com.ibm.ea.smc.console.common.ActionWelcome.execute(ActionWelcome.java:33)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


Top
 Profile  
 
 Post subject: Same error with package name
PostPosted: Thu Jul 20, 2006 11:30 am 
Newbie

Joined: Wed Jul 19, 2006 12:50 pm
Posts: 18
I got the same error when I included the package name in the query.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 20, 2006 12:17 pm 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
You are talking of an error on serviceContinuityApplications query
but the stack trace error is on rolesByRemoteUser query.


Top
 Profile  
 
 Post subject: Error not descriptive
PostPosted: Thu Jul 20, 2006 1:19 pm 
Newbie

Joined: Wed Jul 19, 2006 12:50 pm
Posts: 18
That is why I said the error is not descriptive. When I comment out my query and the mapping in the hibernate config, the error goes away.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 20, 2006 3:44 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
the error you list here could not go away if you remove the query since if you remove the query the query would definitly not be there...

does not make sense.

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 36 posts ]  Go to page 1, 2, 3  Next

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.