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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:21:50+00:00 2026-06-06T15:21:50+00:00

I use Netbeans IDE. My hibernate.cfg.xml looks like this: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE hibernate-configuration

  • 0

I use Netbeans IDE.

My hibernate.cfg.xml looks like this:

<?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>
    //properties

    <mapping resource="entities.Employee"/>
    <mapping resource="entities.Human"/>
  </session-factory>
</hibernate-configuration>

And hibernate.cfg.xml is in

NetBeansProjects\HibernateTest\build\web\WEB-INF\classes\

My code to initialize SessionFactory looks like this:

static {
    try { 
        String configFilePath = "/hibernate.cfg.xml";
        URL configFileURL = SessionFactory.class.getResource(configFilePath);
        sessionFactory = new Configuration().configure(configFileURL).buildSessionFactory();
    } catch (Throwable ex) {
        // Log the exception. 
        throw new RuntimeException(ex);
    }
}

and entites (Employee.class and Human.class) is in

\NetBeansProjects\HibernateTest\build\web\WEB-INF\classes\entities\

Class Employee:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import javax.persistence.*;

@Entity
@Table(name = "EMPLOYEE")
public class Employee implements Serializable {

    public Employee(){
    }

    @Id
    @GeneratedValue(strategy = GenerationType.TABLE)
    @Column(name = "EMPLOYEE_ID")
    private int employeeId;

    @Column(name = "SALARY")
    private double salary;

    @OneToOne(cascade = CascadeType.ALL, fetch= FetchType.LAZY)
    @PrimaryKeyJoinColumn
    private Human humDate;

    public int getEmployeeId() {
        return employeeId;
    }

    public void setEmployeeId(int employeeId) {
        this.employeeId = employeeId;
    }

    public Human getHumDate() {
        return humDate;
    }

    public void setHumDate(Human humDate) {
        this.humDate = humDate;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

}

Class human:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

    package entities;

    import java.io.Serializable;
    import javax.persistence.*;

    @Entity
    @Table(name = "HUMAN")
    public class Human implements Serializable {

        public Human(){
        }

        public Human(String name){
            this.name = name;
        }

        private static final long serialVersionUID = 1L;
        @Id
        @GeneratedValue(strategy = GenerationType.TABLE)
        private int id;

        @Column(name = "HUM_NAME")
        private String name;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getId() {
            return id;
        }

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

        @Override
        public int hashCode() {
            int hash = 0;
            hash += (int) id;
            return hash;
        }

        @Override
        public boolean equals(Object object) {
            // TODO: Warning - this method won't work in the case the id fields are not set
            if (!(object instanceof Human)) {
                return false;
            }
            Human other = (Human) object;
            if (this.id != other.id) {
                return false;
            }
            return true;
        }

        @Override
        public String toString() {
            return "com.nsn.Human[ id=" + id + " ]";
        }

    }

What’s wrong here?

  • 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-06T15:21:52+00:00Added an answer on June 6, 2026 at 3:21 pm

    You should use <mapping class = ... /> instead of <mapping resource = ... />:

    <mapping class = "entities.Employee" />
    <mapping class = "entities.Human" /> 
    

    <mapping resource = ... /> is for mapping with .hbm.xml files rather than annotations.

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

Sidebar

Related Questions

I use Netbeans IDE, some where in the code I included this ImageIcon accept_icon
I currently use Netbeans 7.0.1. From the About Page : Product Version: NetBeans IDE
I make use of: NetBeans IDE 6.7.1, GlassFish v2.1, Oracle 10g XE, JAVA 6
i have installed the cygwin package for my netbeans IDE. I can use that
I use Maven plugin for NetBeans IDE. But i want to know how to
I installed Netbeans IDE 6.8 today to use it while learning Ruby. Here the
Until recently, I've used Symfony 1 and NetBeans IDE. In Netbeans, I could use
Netbeans ide has rails console? I use Netbeans for PHP for a long time,
I prefer to use Netbeans as my IDE rather than Eclipse. A few years
I use Dreamweaver at work and NetBeans IDE at home, but in both cases

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.