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

  • Home
  • SEARCH
  • 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 3434358
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:41:20+00:00 2026-05-18T07:41:20+00:00

I created a Java application that uses Hibernate ORM, with Hibernate tools I get

  • 0

I created a Java application that uses Hibernate ORM, with Hibernate tools I get an automated script that install or upgrades the DB schema from the Java objects used as entities.

The program works properly in MySQL, however for Oracle an error is triggered when in one column the constraint “unique” is declared and after an index is attempted to be defined. Oracle says that a “unique” constraint creates an index by default, so two indexes on the same column cannot be declared,

So, my question is if in MySQL there’s an equivalence or relation between the unique constraint and one index.

Please clarify. Thanks in advanced.

  • 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-18T07:41:21+00:00Added an answer on May 18, 2026 at 7:41 am

    A unique constraint requires a index so it can be enforced. Both DBMS create an appropriate index when you declare columns as unique. The only difference is that Oracle prevents you from creating redundant indexes but MySQL doesn’t:

    show index from test_table;
    
    +------------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
    | Table      | Non_unique | Key_name   | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
    +------------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
    | test_table |          0 | PRIMARY    |            1 | id          | A         |           0 |     NULL | NULL   |      | BTREE      |         |
    | test_table |          0 | foo_unique |            1 | foo         | A         |           0 |     NULL | NULL   |      | BTREE      |         |
    | test_table |          1 | foo_key    |            1 | foo         | A         |           0 |     NULL | NULL   |      | BTREE      |         |
    +------------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JPA/Spring application that uses Hibernate as the JPA provider. In one
My Java application uses db sessions, via Hibernate. What I want to do is
I have a Java application that uses an Apache Derby database with the embedded
I have a Flex/Java web application that uses Maven as a build tool. Currently,
I have a Java web application that uses the SLF4J logging facade. To date,
I've created an app that interacts with a SOAP service using java WS. I
I have a XML schema that I will need to create Java classes for.
I'm trying to implement a Hibernate persistence layer in a Java application and I'm
I want to create a modular(plugin-like) application that uses JPA as its persistence abstraction,
I have a Java enterprise application that provides a web service, has a domain

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.