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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:04:30+00:00 2026-06-09T20:04:30+00:00

I am creating JSF application and using some hibernate stuff in it. All I

  • 0

I am creating JSF application and using some hibernate stuff in it. All I want to do is to save the entity into the database but I keep getting this exception:

org.hibernate.HibernateException: save is not valid without active transaction

At first I was getting this exception:

org.hibernate.HibernateException: No CurrentSessionContext configured!

Then I found that I need to add this into my hibernate configuration:

<property name="hibernate.current_session_context_class">thread</property>

This solved this issue but now the above one appears.
I am saving entity into database like this:

public void create(T entity) {
    getSessionFactory().getCurrentSession().save(entity);
}

My hibernate.cfg.xml file looks like this:

<hibernate-configuration>
    <session-factory>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/online_tests_management</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.connection.password">root</property>
        <property name="hibernate.show_sql">true</property>
        <property name="hibernate.hbm2ddl.auto">update</property>
        <property name="hibernate.current_session_context_class">thread</property>

        <mapping class="com.groupgti.onlinetests.management.db.Service"/>
    </session-factory>
</hibernate-configuration>

I am using:

  • Hibernate-4.1.4.Final
  • JDK 1.6
  • Tomcat 6
  • JSF 2.0
  • PrimeFaces 3.3.1
  • MySql

Does someone know where might be the problem?

  • 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-09T20:04:32+00:00Added an answer on June 9, 2026 at 8:04 pm

    You have to call session.beginTransaction()

    public void create(T entity) {
       Session session=getSessionFactory().getCurrentSession();
       Transaction trans=session.beginTransaction();
       session.save(entity);
       trans.commit();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I creating a web application using JSF,Hibernate,Spring. I have added a filter for checking
I am creating a JSF application. I have some items (e.g. products) from database
Actually I'm creating an application for uploading file using JSF. But whenever I upload
I am creating a form in JSF to save a new entity bean. I
i am creating a web application using jsf and primefaces, and my question is
I'm creating a web based application using Java Server Faces (JSF). I'm just wondering
I am creating page using JSF 2.0 where I am displaying all images that
I'm creating simple example on JSF. It's small Login application. My problem is duplicate
Goal: I want to use jsf`s i18n Scenario: creating resource bundle (utf-8) file info:
I'm creating a JSF 2-application and I'm trying to use form validation in the

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.