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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:08:45+00:00 2026-05-22T01:08:45+00:00

How can I configure Hibernate so it maps beans to some existing tables? P.S:

  • 0

How can I configure Hibernate so it maps beans to some existing tables?

P.S: Each table should correspond with an entity.

Edit: Here is how I used Hibernate with autogenerated tables (taken from a web application). I’m still not clear on how to make the transition to some explicit mapping.

Example Entity bean

@Entity
@Table(name = "t1_category")
// PK is replaced by Long
// See generic definition in abstract class
public class Category extends BaseEntity<Long> {

    @Column(name="check_rsv")
    private String check;

    @Column(unique = true)
    private String name;
    private static final long serialVersionUID = 1L;

    public String getCheck() {
        return this.check;
    }

    public void setCheck(String check) {
        this.check = check;
    }   
    public String getName() {
        return this.name;
    }

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

}

applicationContext.xml/Spring

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:p="http://www.springframework.org/schema/p"
        xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:jee="http://www.springframework.org/schema/jee"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xsi:schemaLocation="
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
            http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

    <context:annotation-config />
    <context:component-scan base-package="***" />


    <bean id="entityManagerFactory"
        class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
        <property name="persistenceUnitName" value="myPersistenceUnit" />
    </bean>

    <!-- Transaction manager for a single JPA EntityManagerFactory (alternative to JTA) -->
    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" 
            p:entityManagerFactory-ref="entityManagerFactory"/>

    <tx:annotation-driven/> <!-- This apparently scans for annotations from the base-package value -->
</beans>

Persistence.xml

<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
    <persistence-unit name="myPersistenceUnit">

    <provider>org.hibernate.ejb.HibernatePersistence</provider>

        <properties>
            <property name="hibernate.archive.autodetection" value="class"/>

          <property name="hibernate.connection.url"
                    value="jdbc:mysql://localhost:3306/***?autoReconnect=true"/>
            <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
            <property name="hibernate.connection.password" value="***"/>
            <property name="hibernate.connection.username" value="***"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>

            <property name="hibernate.hbm2ddl.auto" value="validate"/>

            <property name="hibernate.show_sql" value="true"/>
            <property name="hibernate.format_sql" value="true"/>
            <property name="hibernate.use_sql_comments" value="true"/>
        </properties>
    </persistence-unit>
</persistence>
  • 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-22T01:08:46+00:00Added an answer on May 22, 2026 at 1:08 am

    (What do you mean “fills in”? Map beans to tables? Then:)

    Old way: create Hibernate *.hbm.xml per table/entity. Nothing extraordinary, did it in past.

    New way: create beans, mark them up with the Hibernate annotations.

    New new way: use JPA annotations for portable mapping and Hibernate as JPA implementation.

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

Sidebar

Related Questions

How can I configure hibernate event listeners post-insert, post-delete, post-load, post-update in java configuration?
I can't configure org.hibernate.type (logging bind variables used in hibernate prepared statements) using log4j.xml,
I learned that to configure c3p0 pooling in hibernate, we can have write the
I'm having some difficulty figuring out how to configure my project to use Hibernate.
I found some instructions how to configure pure hibernate to use EHCache. But I
Can I configure hibernate properties to connect without using an instance name to sql
How can I configure hibernate sessionFactory in Spring such that it uses the hibernate.cfg.xml
I know I can configure tt_news to automatically set author and email to a
The users of my app can configure the layout of certain files via a
I'd like to know how I can configure TortoiseHg Workbench so it alawys supplies

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.