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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:58:45+00:00 2026-06-04T23:58:45+00:00

Using Hibernate 4.1.1.Final. When I try to add @ManyToOne, schema creation fails with: org.hibernate.MappingException:

  • 0

Using Hibernate 4.1.1.Final.

When I try to add @ManyToOne, schema creation fails with: org.hibernate.MappingException: Could not instantiate persister org.hibernate.persister.entity.SingleTableEntityPersister

User.java:

@Entity
public class User { 
 @Id
 private int id;
 public int getId() {return id;}
 public void setId(int id) {this.id = id;}
 @ManyToOne
 Department department;
 public Department getDepartment() {return department;}
 public void setDepartment(Department department) {this.department = department;}
}

Department.java

@Entity
public class Department {
 @Id
 private int departmentNumber;
 public int getDepartmentNumber() {return departmentNumber;}
 public void setDepartmentNumber(int departmentNumber) {this.departmentNumber = departmentNumber;}
}

hibernate.properties:

hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://localhost:3306/dbname
hibernate.connection.username=user
hibernate.connection.password=pass
hibernate.connection.pool_size=5
hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
hibernate.hbm2ddl.auto=create

init (throwing exception):

ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().buildServiceRegistry();
sessionFactory = new MetadataSources(
serviceRegistrY.addAnnotatedClass(Department.class).addAnnotatedClass(User.class).buildMetadata().buildSessionFactory();

exception throwed at init:

org.hibernate.MappingException: Could not instantiate persister org.hibernate.persister.entity.SingleTableEntityPersister
    at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:174)
    at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:148)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:820)
    at org.hibernate.metamodel.source.internal.SessionFactoryBuilderImpl.buildSessionFactory(SessionFactoryBuilderImpl.java:65)
    at org.hibernate.metamodel.source.internal.MetadataImpl.buildSessionFactory(MetadataImpl.java:340)

I have tried adding some other annotations, but shouldn’t the defaults work and create the tables and foreign key? If I remove the department from User, tables get generated fine.

Thanks in advance!

  • 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-04T23:58:46+00:00Added an answer on June 4, 2026 at 11:58 pm

    You are using features not yet complete. Everything in org.hibernate.metamodel is targetting 5.0.

    http://docs.jboss.org/hibernate/orm/4.1/javadocs/org/hibernate/metamodel/package-summary.html

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

Sidebar

Related Questions

Using Hibernate 3.6.8.Final and Spring 3.0.5.RELEASE , I'm trying to add some Common DAO
I'm using Hibernate 4.0.1.Final. I'm having trouble binding a session when testing my service.
I'm using Hibernate 4.0.1.Final to write a standalone Java app. When testing my data
I'm using Hibernate 4.0.1.Final. I'm trying to run a JUnit test on my DAO
I'm using Hibernate 4.0.1.Final. I have a table with a unique constraint column …
I'm using Hibernate 4.0.1.Final and MySQL 5.1. My domain object contains a java.util.Calendar object
When using hibernate to retrieve data from Oracle 11g DB using either org.hibernate.dialect.Oracle10gDialect or
When using Hibernate 2nd level cache and query cache and not specifying anything inside
I'm using Hibernate 3.5.2-FINAL with annotations to specify my persistence mappings. I'm struggling with
i am using hibernate validation (4.2.0 Final) with JSF 2 and Spring and here's

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.