Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1072519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:52:16+00:00 2026-05-16T20:52:16+00:00

Hi i am trying to execute this simple HQL query to get a list

  • 0

Hi i am trying to execute this simple HQL query to get a list of files from my database using:

private static final String SQL_GET_FILE_LIST = "select filename, size, id, type from fileobject";

@Override
public List<FileObject> getFileList(String type) {
    // TODO Auto-generated method stub
    List<FileObject> files = hbTemplate.find(SQL_GET_FILE_LIST);
    hbTemplate.flush();
    return files;
}

but i keep getting this exception:

  org.hibernate.hql.ast.QuerySyntaxException: fileobject is not mapped [select filename, size, id, type from fileobject]
    org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:158)
    org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:87)
    org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:70)
    org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:257)
    org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3056)
    org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2945)
    org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
    org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
    org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
    org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
    org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228)
    org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
    org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
    org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
    org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
    org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
    org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
    org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
    org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
    org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:923)
    org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
    org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
    org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:921)
    org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:913)
    com.kc.models.DbFileHelper.getFileList(DbFileHelper.java:65)
    com.kc.models.FileHelper.getFileList(FileHelper.java:108)
    com.kc.Controllers.AppListController.getFileList(AppListController.java:63)
    com.kc.Controllers.AppListController.handleRequest(AppListController.java:34)
    org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

my hbm.xml file

<?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 package="com.kc.models.FileObject" >

    <class name="com.kc.models.FileObject" table="fileobject">
        <id name="id" column="ID">
            <generator class="native" />
        </id>
        <property name="filename" type="string" column="FILENAME" />
        <property name="type" type="string" column="TYPE" />
        <property name="size" type="double" column="SIZE" />
        <property name="file" type="blob" length="1000000000" column="FILE" />
    </class> 

</hibernate-mapping> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:52:17+00:00Added an answer on May 16, 2026 at 8:52 pm

    Well, first of all, as the trace says, fileobject is not mapped but FileObject is. So change your HQL query into:

    select filename, size, id, type from FileObject
    

    Second, since you’re using projections, you won’t get a List<FileObject> but a List<Object[]>. So your code should be:

    private static final String SQL_GET_FILE_LIST = "select filename, size, id, type from FileObject";
    
    @Override
    public List<Object[]> getFileList(String type) {
        // TODO Auto-generated method stub
        List<Object[]> files = hbTemplate.find(SQL_GET_FILE_LIST);
        hbTemplate.flush();
        return files;
    }
    

    Or, if you want to get a type safe result, you could use a constructor expression (assuming your class is providing the appropriate constructor):

    select new FileObject(filename, size, id, type) from FileObject
    

    And then you could use your current code.

    private static final String SQL_GET_FILE_LIST = "select new FileObject(filename, size, id, type) from FileObject";
    
    @Override
    public List<FileObject> getFileList(String type) {
        // TODO Auto-generated method stub
        List<FileObject> files = hbTemplate.find(SQL_GET_FILE_LIST);
        hbTemplate.flush();
        return files;
    }
    

    Reference

    • Hibernate Core Reference Guide
      • 14.6. The select clause
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble getting this simple query to execute. I'm using nameless parametized queries
I have simple query, but when I'm trying to execute this query I'm getting
I'm trying to execute a simple batch file from java using Runtime.getRuntime().exec(command); but facing
I'm trying to back a database via a PHP script using this one simple
I'm trying to execute this function when a select list's (LevelId0) value change but
I've been trying to execute this mysql query in my php file however I
I have a problem when trying to execute this update statement (below) using C#
I'm trying to execute this simple command: create table foo (clo int primary key
I'm trying to execute a simple stored procedure with Spring/Hibernate using Annotations. Here are
I have been working on my Ruby. When trying to execute this simple example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.