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

  • Home
  • SEARCH
  • 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 8947793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:51:28+00:00 2026-06-15T12:51:28+00:00

Im moving to java from C#, this is my frist try at actually writting

  • 0

Im moving to java from C#, this is my frist try at actually writting something and I’m trying to setup my data layer, but I think I’m missing something like DataContext in LINQ to SQL in .NET

Im trying to query database using Hibernate but it seems like I’m missing something, I downloaded Hibernate 4 and QueryDSL for type safe queries.

Next I connected to my postgreSQL database and generated DAO objects using Dali(I think? in menu I selected JPA enteties from tables), written queries that I need but I am unsure which object I have to execute my query on (something like connection manager or something?)

Im missing something here I think:

EmployeesRepository repo = new EmployeesRepository();
List<Employees> employees = repo.GetByName("Steve");
Employees s = employees.get(0);
String g = s.getName();

My entity repository:

public class EmployeesRepository {

    public List<Employees> GetByName(String ename)
    {
        HibernateQuery qry = createQuery(employees);
        qry.where(employees.name.like(ename));
        return qry.list(employees);
    }

    private HibernateQuery createQuery(QEmployees employee)
    {
        return new HibernateQuery().from(employee);
    }
}

Im getting:

java.lang.UnsupportedOperationException: No session in detached Query available

  • 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-15T12:51:29+00:00Added an answer on June 15, 2026 at 12:51 pm

    You need to create/open a hibernate session before executing query.

    Example:

    Session session = HibernateUtil.getSessionFactory().openSession();
    

    When you are done with query execution, you need to close.

    session.close();
    

    Here is step by step example.

    Note: There may be a hibernate version mismatch between what you are using and the one described in above example, you may need to just tweek it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to C++, moving from Java and wondering about this: pos =
I am moving to C++ from Java and I am having a lot of
I'm developer moving from C# to Java. Heard about new ASP net feature. <%:
I'm moving from Java to C++ right now and I'm having some difficulties whenever
I am having growing pains moving from Java to C. I have become used
I have been moving my Java projects from Jdeveloper over to Eclipse whenever I
I am just trying to familiarise myself with the basics of C++ moving from
Im trying to append some JSON data from the last.fm API, I have been
Coming from java/groovy/grails we are currently moving to rails. We have been having an
While I was trying something special in for loop I recognized that Java doesn't

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.