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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:07:14+00:00 2026-05-16T15:07:14+00:00

I’m using netbeans 6.9 and Hibernate and I’m trying to insert some values in

  • 0

I’m using netbeans 6.9 and Hibernate and I’m trying to insert some values in a database (postgres) but I get the following exception:

INFO: Not binding factory to JNDI, no JNDI name configured
Exception in thread "main" org.hibernate.MappingException: Unknown entity: SELECTPACK.beanClass
        at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:550)
        at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1338)
        at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:98)
        at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
        at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:3

and my hbm.xml file is given below

<class name="SELECTPACK.beanClass" table="login">
  <id column="id" name="id">
      <generator class="increment"/>
  </id>
  <property name="username" column="username"/>
  <property name="password" column="password"/>
</class>

my cfg.xml file is given below

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
        <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
        <property name="hibernate.connection.url">jdbc:postgresql://192.168.1.100:54321/postgres</property>
        <property name="hibernate.connection.username">postgres</property>
        <property name="hibernate.connection.password">dbserver</property>
        <property name="hibernate.show_sql">true</property>
        <mapping resource="SELECTPACK/select.hbm.xml"/>
    </session-factory>
</hibernate-configuration>

my pojo class

package SELECTPACK;

public class beanClass {
    private int id;
    private String username;
    private String password;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }
}

and hear is my main class

package SELECTPACK;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

public class selectMainClass {

    public static void main(String... args) {
        SessionFactory sessionFact = new Configuration().configure().buildSessionFactory();
        Session ses = sessionFact.openSession();
        Transaction tx = ses.beginTransaction();
        beanClass bean = new beanClass();
        bean.setPassword("hi....");
        bean.setUsername("hi....");
        ses.save(bean);
        tx.commit();
        /*String query = "select * from login";
        Query qry = ses.createQuery(query);
        ArrayList list = (ArrayList) qry.list();
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }*/
        ses.close();
    }
}

I don’t understand what the problem is.

  • 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-16T15:07:14+00:00Added an answer on May 16, 2026 at 3:07 pm

    The entity SELECTPACK.beanClass is not recognized as a valid entity and there should be a previous stacktrace in the log (when creating the SessionFactory) showing the real error. Look for a previous trace. But possible causes include:

    • the table doesn’t exist
    • one of the mapped column is not there

    Apart from that, I have a few minor remarks (that are not the problem):

    • traditionally, packages are in lower case (i.e. selectpack);
    • the Java class name should start with an upper case letter (i.e. BeanClass);
    • it is recommended to map a class selectpack.BeanClass in a selectpack/BeanClass.hbm.xml mapping file (to ease the maintenance);
    • my suggestion would be to use the native generator in the mapping file.

    Something like this for the class:

    package selectpack;
    
    public class BeanClass {
        private int id;
        private String username;
        private String password;
    
        public int getId() {
            return id;
        }
    
        public void setId(int id) {
            this.id = id;
        }
    
        public String getPassword() {
            return password;
        }
    
        public void setPassword(String password) {
            this.password = password;
        }
    
        public String getUsername() {
            return username;
        }
    
        public void setUsername(String username) {
            this.username = username;
        }
    }
    

    And for the mapping 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>
        <class name="selectpack.BeanClass" table="login">
          <id column="id" name="id">
              <generator class="native"/>
          </id>
          <property name="username" column="username"/>
          <property name="password" column="password"/>
        </class>
    </hibernate-mapping>
    

    Of course, update the hibernate.cfg.xml accordingly:

       <mapping resource="selectpack/BeanClass.hbm.xml"/>
    

    But as I said, these remarks are not directly related to the problem.

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

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.