-->
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.  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: where to define actual typesafe Java object & let HQL kn
PostPosted: Wed Oct 26, 2005 12:25 am 
Beginner
Beginner

Joined: Mon Sep 19, 2005 3:59 pm
Posts: 31
Hi there,

how can I define an actual typesafe Java object, and HQL can find it?
Thanks for any help.

Lamborghini

Code:
         Query query = session
               .createQuery("select new UserView(userid, username, name, role) from Systemuser where username = :UserName and pin = :Password");
         query.setParameter("UserName", userName);
         query.setParameter("Password", password);
         resultSet = (UserView) query.uniqueResult();[code][/code]

Log:

ERROR http-80-Processor24 org.hibernate.hql.PARSER - *** ERROR:  Unable to locate class [UserView]
[cause=java.lang.ClassNotFoundException: UserView]
DEBUG http-80-Processor24 org.hibernate.hql.ast.ErrorCounter -  Unable to locate class [UserView]
[cause=java.lang.ClassNotFoundException: UserView]
  Unable to locate class [UserView]
[cause=java.lang.ClassNotFoundException: UserView]
   at org.hibernate.hql.ast.ConstructorNode.resolveConstructor(ConstructorNode.java:115)
   at org.hibernate.hql.ast.ConstructorNode.prepare(ConstructorNode.java:86)
   at org.hibernate.hql.ast.HqlSqlWalker.processConstructor(HqlSqlWalker.java:543)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExpr(HqlSqlBaseWalker.java:1598)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExprList(HqlSqlBaseWalker.java:1467)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectClause(HqlSqlBaseWalker.java:1041)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:380)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:201)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:151)
   at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
   at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)
   at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
   at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427)
   at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:884)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:834)
   at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
   at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:603)
   at com.articy.security.SecurityService.login(SecurityService.java:61)
   at com.articy.security.action.LoginAction.execute(LoginAction.java:52)
   at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
   at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
   at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
   at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
   at com.articy.utils.SetEncodingFilter.doFilter(SetEncodingFilter.java:50)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
   at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
   at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
   at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
   at java.lang.Thread.run(Thread.java:534)
Cause:
java.lang.ClassNotFoundException: UserView
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1340)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
   at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Class.java:141)
   at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
   at org.hibernate.hql.ast.ConstructorNode.resolveConstructor(ConstructorNode.java:111)
   at org.hibernate.hql.ast.ConstructorNode.prepare(ConstructorNode.java:86)
   at org.hibernate.hql.ast.HqlSqlWalker.processConstructor(HqlSqlWalker.java:543)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExpr(HqlSqlBaseWalker.java:1598)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExprList(HqlSqlBaseWalker.java:1467)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectClause(HqlSqlBaseWalker.java:1041)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:380)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:201)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:151)
   at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
   at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)
   at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
   at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427)
   at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:884)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:834)
   at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
   at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:603)
   at com.articy.security.SecurityService.login(SecurityService.java:61)
   at com.articy.security.action.LoginAction.execute(LoginAction.java:52)
   at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
   at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
   at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
   at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
   at com.articy.utils.SetEncodingFilter.doFilter(SetEncodingFilter.java:50)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
   at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
   at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
   at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
   at java.lang.Thread.run(Thread.java:534)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 26, 2005 12:53 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
I don't think the problem is so much getting "HQL to find it".

UserView.class needs to be in the classpath .


Top
 Profile  
 
 Post subject: UserView Code
PostPosted: Wed Oct 26, 2005 9:01 am 
Beginner
Beginner

Joined: Mon Sep 19, 2005 3:59 pm
Posts: 31
Yes, I do have the class in my project, and coded as below

Code:
package view;


public class UserView implements java.io.Serializable {
   /**
    *
    */
   private static final long serialVersionUID = 1L;

   private Integer userid;

   private String username;

   private String name;

   private String role;

   public UserView(Integer m_userid, String UserName, String Fullname, String userPermissions) {
      super();
      userid = m_userid;
      username = UserName;
      name = Fullname;
      role = userPermissions;
   }

   public Integer getUserid() {
      return userid;
   }

   public void setUserid(Integer m_userid) {
      this.userid = m_userid;
   }

   public String getUsername() {
      return username;
   }

   public void setUserName(String m_username) {
      username = m_username;
   }

   public String getName() {
      return name;
   }

   public void setName(String fullname) {
      name = fullname;
   }

   public String getRole() {
      return role;
   }

   public void setRole(String userPermissions) {
      name = userPermissions;
   }

}


Top
 Profile  
 
 Post subject: Re: UserView Code
PostPosted: Wed Oct 26, 2005 9:17 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
What does your mapping file look like for this class ?

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject: It may be the point
PostPosted: Wed Oct 26, 2005 9:31 am 
Beginner
Beginner

Joined: Mon Sep 19, 2005 3:59 pm
Posts: 31
Hi Pksiv,

I am newbie to Struts and Hibernate, copied the code from sample and revised it.

:-( and I don't know what kind of mapping file I need. Could you please give me more details?

Thanks in advance.

Lamborghini


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 26, 2005 9:35 am 
Senior
Senior

Joined: Thu Aug 04, 2005 4:54 am
Posts: 153
Location: Birmingham, UK
You need to supply User.hbm.xml which is the mapping file for the User class.

If you're still confused over what a mapping file is, check the documentation again including the getting started guide.


Top
 Profile  
 
 Post subject: Re: It may be the point
PostPosted: Wed Oct 26, 2005 9:35 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
lamborghini wrote:
Hi Pksiv,

I am newbie to Struts and Hibernate, copied the code from sample and revised it.

:-( and I don't know what kind of mapping file I need. Could you please give me more details?

Thanks in advance.

Lamborghini


Your hibernate mapping file. Should be named something like UserView.hbm.xml

If you don't understand this, you should walk through a few more tutorials before you post questions here.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject: Only want to put the info into one class
PostPosted: Wed Oct 26, 2005 9:51 am 
Beginner
Beginner

Joined: Mon Sep 19, 2005 3:59 pm
Posts: 31
As I understood, the mapping file is used to bridge the table and the object.

What I need is just retrieve the logging user and put the users userid, username, full name and role in the object UserView for session. Do I still need the mapping file? or I have another way to do that?


Thanks,

Lamborghini


Top
 Profile  
 
 Post subject: Re: Only want to put the info into one class
PostPosted: Wed Oct 26, 2005 9:53 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
You can't do anything with Hibernate without mapping the objects.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject: UserView.hbm.xml
PostPosted: Wed Oct 26, 2005 11:36 am 
Beginner
Beginner

Joined: Mon Sep 19, 2005 3:59 pm
Posts: 31
<?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" >

<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration. -->
<!-- Created Mon Oct 10 09:07:55 EDT 2005 -->
<hibernate-mapping package="com.articy.security.view">

<class name="UserView" table="systemuser">
<id name="userid" column="userid" type="integer">
<generator class="sequence">
<param name="sequence">user_id_seq</param>
</generator>
</id>

<property name="role" column="role" type="java.lang.String" />
<property name="username" column="username" type="java.lang.String" not-null="true" />
<property name="name" column="name" type="java.lang.String" />

</class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject: seems sth wrong in thx mapping file
PostPosted: Wed Oct 26, 2005 11:44 am 
Beginner
Beginner

Joined: Mon Sep 19, 2005 3:59 pm
Posts: 31
the above mapping file caused some problem, but I cannot figure out it, could you please give me some ideas?

TIA
Lamborghini


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 26, 2005 12:15 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
if you use the new syntax, then remember to use the fully qualifed name or perform a <import> on it in your mapping file.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 26, 2005 12:17 pm 
Senior
Senior

Joined: Thu Aug 04, 2005 4:54 am
Posts: 153
Location: Birmingham, UK
Your setter for username is wrong.

You've got setUserName instead of setUsername

Fix that error and come back with stack traces of errors that occur.


Top
 Profile  
 
 Post subject: Can I just map some fields of one table
PostPosted: Wed Oct 26, 2005 2:04 pm 
Beginner
Beginner

Joined: Mon Sep 19, 2005 3:59 pm
Posts: 31
Hi there,

in mapping file, is it possible to map some fields of one table instead of all
fields?

in such case, I have 20 fields in one table, but in a POJO, I only need 5 of them.

Lamborghini


Top
 Profile  
 
 Post subject: Re: Can I just map some fields of one table
PostPosted: Wed Oct 26, 2005 2:36 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
lamborghini wrote:
Hi there,

in mapping file, is it possible to map some fields of one table instead of all
fields?

in such case, I have 20 fields in one table, but in a POJO, I only need 5 of them.

Lamborghini



You can get away with only mapping the columns you want but if you perform inserts, those fields must be nullable. Or define the mapping as mutable="false"

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


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