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 8191421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:54:59+00:00 2026-06-07T03:54:59+00:00

I am implementing a Restful Web Service using Jersey. I have a package using

  • 0

I am implementing a Restful Web Service using Jersey. I have a package using hibernate to map the data to DB.
I am new to hibernate using DAO :

I have a method in GenericDao class :

public abstract class GenericDAO<T> extends DAOFactory {

    private final Class classe;

        public GenericDAO(Class classe) {
            this.classe = classe;
        }

           public List<T> findByCriteria(List<Criterion> list) throws Exception {
                Criteria criteria = getSession().createCriteria(classe);
                for (int i = 0; i < list.size(); i++) 
                   criteria.add(list.get(i));
                return criteria.list();
            }
        }

Then I have my DAO classes like :

public class TaskDAO extends GenericDAO<Task> {

    public TaskDAO() {
        super(Task.class);
    }
}

Then I use this method in a Service class and it works completely fine like this:

 public Response get(long projectId, String username) {
    List<Criterion> list = new ArrayList<Criterion>();
    Criterion c = Restrictions.eq("project.id", projectId);
    list.add(c);
    List<Deliverable> deliverables = deliverableDAO.findByCriteria(list);
    return deliverables
}

The problem is in this method in another Service class :

public Response get(String username) {
    List<Criterion> list = new ArrayList<Criterion>();
    Criterion c = Restrictions.eq("user.username", username);
    list.add(c);
    List<Task> tasks = taskDAO.findByCriteria(list);
    return tasks;
}

as you see “Restrictions.eq(“project.id”, projectId)” works fine for me but “Restrictions.eq(“user.username”, username)” has a promlem maybe with ‘user.username’,
Any help?

The error in the stack trace is like:

javax.ws.rs.WebApplicationException: org.hibernate.QueryException: could not resolve property: user.username of: se.softwerk.timelog.model.Task
    at se.softwerk.controller.services.TaskService.get(TaskService.java:29)
    at se.softwerk.timelog.controller.TaskManager.taskList(TaskManager.java:72)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
    at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
    at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
    at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
    at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:298)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.QueryException: could not resolve property: user.username of: se.softwerk.timelog.model.Task
    at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:83)
    at org.hibernate.persister.entity.AbstractPropertyMapping.toColumns(AbstractPropertyMapping.java:98)
    at org.hibernate.persister.entity.BasicEntityPropertyMapping.toColumns(BasicEntityPropertyMapping.java:61)
    at org.hibernate.persister.entity.AbstractEntityPersister.toColumns(AbstractEntityPersister.java:1801)
    at org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumns(CriteriaQueryTranslator.java:522)
    at org.hibernate.loader.criteria.CriteriaQueryTranslator.findColumns(CriteriaQueryTranslator.java:537)
    at org.hibernate.criterion.SimpleExpression.toSqlString(SimpleExpression.java:66)
    at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:419)
    at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:123)
    at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:92)
    at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:93)
    at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1464)
    at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:374)
    at se.softwerk.timelog.model.dao.GenericDAO.findByCriteria(GenericDAO.java:33)
    at se.softwerk.controller.services.TaskService.get(TaskService.java:24)
  • 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-06-07T03:55:00+00:00Added an answer on June 7, 2026 at 3:55 am

    You need to create a join to be able to access the fields of the user of the task:

    criteria.createAlias("user", "theUser");
    criteria.add(Restrictions.eq("theUser.username", username);
    

    You don’t need to do it for the ID of the project of the task, because the ID of the project is stored, as a foreign key, in the task table directly.

    Design note: your DAO doesn’t add much value. In particular, it doesn’t isolate the service class from the persistence API (Hibernate, in this case). You might use the Hibernate session directly in your service class, and it wouldn’t change much. Completely isolating the service class from the persistence API is useful for two main reasons:

    • it makes responsibilities clearer: the service class contains business logic, while the DAO contains persistence logic
    • it allows mocking the DAO in order to unit test the service.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am implementing a RESTful Web Service using Jersey. I use hibernate to communicate
I am implementing a Restful Web Service using Jersey. I want to show index.jsp
I have succesfully implemented a RESTful Web Service using the .NET 4.0 framework with
I am implementing a Restful Web Service in java (JAX-RS) using Jesey. I run
I am exploring the idea of implementing a web service api using WCF Data
Implementing a simple Login screen using JSF and Spring and Hibernate. I have written
I'm implementing a RESTful web service in python and would like to add some
I have just started reading on implementing RESTful web services and creating RESTful apis.
I am attempting to add BASIC authentication to my RESTful web-service. Currently I have
I want to implement spring security on a jersey Restful web service, both on

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.