Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-dev] adding support for creation of column indices

Hi Dies,

The sounds like a good plan. Following the pattern used by foreign key constraints is definitely a good guideline.

FYI: There are two places you will want to ensure this works. The majority of our testing uses subclasses of TableCreator that are explicitly defined. You will also want to test with our JPA DDL generation. The functionality is defined in: org.eclipse.persistence.tools.schemaframework.DefaultTableGenerator. Based on your plan it is possible you will not have to make any modifications there, but it is something to be aware of. There is testing of this functionality as part of our JPA suite.

-Tom


Dies Koper wrote:
This is what I would try:

Add createIndices, dropIndices, replaceIndices methods to TableCreator, which forward calls to SchemaManager (similar as done for constraints and tables). These again forward to TableDefinition, which can generate the CREATE INDEX statements based on what's in uniqueKeys (or obtained from getFields() like getPrimaryKeyFieldNames() does).

Add invocations to TableCreator#create/drop/replaceIndices from TableCreator#create/drop/replaceTables (at the end, after processing the sequences when creating, at the start when dropping).

In the TableDefinition's methods I can check whether this platform actually requires the indices created/dropped (as is done for constraints).

Would that be the best way?

Thanks,
Dies Koper


Dies Koper wrote:
Hi Tom, all,

As I mentioned in my previous e-mail, I'm trying to run the
foundation/eclipselink.core.test JUnit tests on the Symfoware platform.
Most of them currently fail.

Some are issues with restrictions in Symfoware DB (like you cannot use a
reserved keyword as column name (e.g. "LANGUAGE")), a few others I need
to look at in more detail.

But most are failing because Symfoware DB needs you to create an index
for tables with a unique constraint. That means that for any
auto-generated table with a PRIMARY KEY, I currently get an error when
performing a CRUD on the table.

When we created the Symfoware platform class I didn't see this as a
major restriction, I assumed in production systems people would be
creating their own DDL scripts with tuning parameters and indices etc.).

But as the unit tests would be a great base for regression testing for
the Symfoware platform, I'm trying to think of a way to get it working
anyway.
I'd like to explore the possibility of having EclipseLink create the
required indices when creating tables.

So for each create table statement such as the following, I need a
create index statement such as the one below:

CREATE TABLE EJB.CUSTOMER (
             ID          VARCHAR(128)  NOT NULL ,
             NAME        VARCHAR(128)  NOT NULL ,
             AGE         VARCHAR(128) ,
             PRIMARY KEY (ID,NAME)
);

CREATE INDEX EJB.CUSTOMER.IDX1 KEY(ID,NAME);

Is there a particular suitable place in the code where to do this, where
I can obtain a list of tables that are to be created (or just after the
generation of each table DDL) and retrieve which columns have
unique/primary constraints, so I can hook in a platform specific
callback method to insert the index creation DDL for Symfoware so that
the existing code automatically sends it to the DB and/or file?
Or is there already such a functionality in EclipseLink that I just need
to enable?

Thanks!
Dies Koper

_______________________________________________
eclipselink-dev mailing list
eclipselink-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev


Back to the top