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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:36:36+00:00 2026-05-16T18:36:36+00:00

I have this entity class, the first one I built to test Hibernate, it

  • 0

I have this entity class, the first one I built to test Hibernate, it uses an oracle sequence to fill the ID field :

@Entity
@Table(name="COMPANIES")
public class Companies {

                private Integer cmpid;
                private String cmpname;
                private String cmpcountry;

                public Companies() {

                }

                public Companies(String name, String country) {
                    this.cmpname = name;
                    this.cmpcountry = country;
                }
                    @Id
                    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "gen_CMP")
                    @SequenceGenerator(name="gen_CMP", sequenceName = "CMP_ID_SEQ")
                    @Column(name="CMP_ID", nullable=false)
                    public Integer getCmpId() {
                    return this.cmpid;
                    }

                    public void setCmpId(Integer cmpid) {
                    this.cmpid = cmpid;
                    }

                    @Column(name="CMP_NAME", nullable=true)
                    public String getCmpName() {
                    return this.cmpname;
                    }

                    public void setCmpName(String cmpname) {
                    this.cmpname = cmpname;
                    }

                    @Column(name="CMP_COUNTRY", nullable=true)
                    public String getCmpCountry() {
                    return this.cmpcountry;
                    }

                    public void setCmpCountry(String cmpcountry) {
                    this.cmpcountry = cmpcountry;
                    }

}

Then in my Test Unit, I create a Companies object then save it in the session:

Companies Companies = new Companies("qqq","FR");
session.save(Companies);
transaction.commit();

But every time, it delete ALL the records in the COMPANIES table in Oracle.

So the first time I tried on my data, it was filled with many rows, and with this primary keys used in other tables, and it was able to delete those rows in Companies and not the other tables…

So it means Hibernate actually disabled all my constraints, empty the table, and added the new row from my Test Unit…

What am I doing wrong?

I don’t want hibernate to mess with my data unless I tell it to do so…

  • 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-16T18:36:37+00:00Added an answer on May 16, 2026 at 6:36 pm

    In your hibernate configuration you need to set hbm2dll to validate. Something like this:

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

    If it is set to create it will drop and re-create your database tables every time it runs.

    This page describes the setting in more detail.

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

Sidebar

Related Questions

suppose that I have this RDBM table ( Entity-attribute-value_model ): col1: entityID col2: attributeName
I have a large application that uses EJB 2.x entity beans (BMP). This is
A have a JPA entity that has timestamp field and is distinguished by a
I started creating JPA/hibernate mappings for a legacy database based on Oracle. At one
I have this code in jQuery, that I want to reimplement with the prototype
I have this idea for a free backup application. The largest problem I need
I have this gigantic ugly string: J0000000: Transaction A0001401 started on 8/22/2008 9:49:29 AM
I have this line in a javascript block in a page: res = foo('<%=
I have this setup where in my development copy I can commit changes on
I have this string 'john smith~123 Street~Apt 4~New York~NY~12345' Using JavaScript, what is the

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.