Community
Participate
Working Groups
Build Identifier: 2.3.0.v20110604-r9504 When creating a table (using the setting "eclipselink.ddl-generation=drop-and-create-tables" or "create-tables"), EclipseLink will also create any indices that were specified using the @Index annotation. However, if the index creation fails (for example because the column names specified in the annotation are incorrect), EclipseLink will log this as "default_tables_already_existed" and continue. First, the error message is wrong (EcliseLink seems to assume that errors during table creation are always caused by the table already existing). Secondly, at least in testing scenarios (where automatic table creation is particularly useful), it makes more sense to treat errors during index creation as fatal (as they may indicate a problem with the database schema). The error message should be corrected. Proposal: "error creating table XXX (maybe exists already?)". Also, there should be a way to specify that errors during table creation are fatal. At least when drop-and-create is used, there should be no errors during table creation, so making creation errors fatal would be useful. Reproducible: Always Steps to Reproduce: 1. Create a simple EclipseLink project, with a persisted entity. 2. Annotate the entity with @Index(name="TEST_INDEX", columnNames={"DOESNOTEXIST"}) 3. Enable table creation in persistence.xml: <property name="eclipselink.ddl-generation" value="drop-and-create-tables" /> 4. Run program. The error during index creation will be logged (as an org.eclipse.persistence.exceptions.DatabaseException), but the program will continue normally.
The underlying problem is apparently that EclipseLink assumes that all errors during table creation are caused by the table already existing. During table creation, all exceptions are caught and logged as "default_tables_already_existed". See class TableCreator, method createTables. This is incorrect, as the creation of a table can fail for other reasons. Incorrect @Index annotations, as in this bug, are only one case. Similar problems would occur if a table used reserved words of the database, or if the user does not have create table permissions, or if the DBMS is out of space... Just treating all errors as "table exists" seems ill-advised.
Ideally, EclipseLink should distinguish errors caused by an existing table from others and treat them separately. If that is not feasible, it should at least be configurable how they are treated. Proposal (just an idea): A property "eclipselink.ddl-generation.create-error-handling". Possible values: "ignore" - log error as FINE and continue "fail" - don't catch DatabaseException, let it bubble up "ignore-for-create-tables" - ignore errors if "create-tables" is used, but fail if "drop-and-create-tables" is used (on the assumption that errors caused by existing tables should not occur if we dropped them first) The option "ignore-for-create-tables" might be a reasonable default.
Bgu #281947 looks related, as it is probably also caused by the table creation ignoring any errors.
Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines Community: Please vote for this bug if it is important to you. Votes are one of the main criteria we use to determine which bugs to fix next.
+1 please at least throw an exception when something goes wrong during ddl generation, the silent fail is causing many headaches. Right now i'm looking at a @CollectionTable that is not created when connecting to Oracle, but when we point to an in-memory H2 it is created without problem. We have no idea why.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink