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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:52:37+00:00 2026-05-27T22:52:37+00:00

I have a Data Class for Hibernate associated to a table; imagine the Entity

  • 0

I have a Data Class for Hibernate associated to a table; imagine the Entity Person like this:

 @Entity
 @org.hibernate.annotations.Proxy(lazy=false)
 @Table(name="Person", schema="MySchema")
 @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
 public class ProfileData implements Serializable {

    private static final long serialVersionUID = -844564646821609090L;

    public PersonData() {
    }

    @Column(name="idPerson", nullable=false, unique=true)   
    @Id 
    ...

I need to create historic tables by years of this table: Person2010, Person2011, Person2012… Is it possible without creating new Data Objects? Maybe by a parameter…? I don´t know.

The Entity class is the same, changing the table name and the constructor.

  • 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-27T22:52:38+00:00Added an answer on May 27, 2026 at 10:52 pm

    Another one Architecture, more complez but elegant:

    YES, You can change the table names using NamingStrategies:

    public class MyNamingStrategy extends DefaultNamingStrategy {
       ...
       @Override
       public  String tableName(String tableName) {
          return tableName+yearSuffixTable;
       }
       ...
    }
    

    And, when you wanna to use the _year tables, you must to create a session with Hibernate that override rhe table names:

      SessionFactory sessionFactory;
      Configuration config = new AnnotationConfiguration()
                             .configure("hibernate.cfg.xml")
                             .setNamingStrategy( new MyNamingStrategy () );
      sessionFactory = config.buildSessionFactory();
      session = sessionFactory.openSession();
    

    For my architecture I create a session by year and store it into Application map for access when I need it.

    Thanks.

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

Sidebar

Related Questions

I have a hibernate mapping as follows: <hibernate-mapping> <class name=kochman.elie.data.types.InvoiceTVO table=INVOICE> <id name=id column=ID>
I have the following mapping: <hibernate-mapping package=server.modules.stats.data> <class name=User table=user> <id name=id> <generator class=native></generator>
Let's say I have data structures that're something like this: Public Class AttendenceRecord Public
Technology: Hibernate 3.0 Suppose i have Entity class Company @Entity @Table(name=tbl_companies) public class Company
I have a Data Class called MyTable, and the source property is TABLE (table
I have a Hibernate class called Expression (simplified here for your viewing pleasure): @Entity
We are using grails-groovy with Hibernate, I have a SQL query like this in
I have a domain class in grails 1.5 that represents data from a table
I have this propery in my entity class: @Column(name=avatar,nullable=false,length=1000) String getAvatarData() { return new
A typical JPA entity looks like: @Entity public class Person { @Id private int

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.