yes, thats exactly what I meant with the adaptations I'd like to make!
Did you mean the constraint naming should be added to the existing code for the table and
column naming strategy?
I'd prefer to implement a new interface/class structure:
->DefaultConstraintNamingStrategy (Implementation class)
1) the existing interface 'NamingStrategy' has not to be changed
2) and the NamingStrategy for table/column names and constraint
names can be configured independently.
What do you think about this?
I checked the actual SVN sources but I could not find the code you mentioned where the
maximum allowed length of column and table names is checked. Can you give me a hint?
Anyway I would include this in the constraint naming implementation.
-------- Original-Nachricht --------
Datum: Fri, 31 Oct 2008 16:41:34 +0100
Von: "Max Rydahl Andersen" <max.andersen(a)redhat.com>
An: "Jürgen Avian" <javian(a)gmx.net>, hibernate-dev(a)lists.jboss.org
Betreff: Re: [hibernate-dev] Constraint naming in HBM2DDL schema export
These should be on the existing NamingStrategy, not Dialect.
They also needs to obey length limits on constraints - many dbs does not
allow so long ones.
It is not currently being implemented so feel free to contribute a patch
(most likely for 3.4 since it will break/change API)
> some time ago I added the following feature to the Hibernate Core:
> Automated naming of the constraint types in the hbm2ddl schema export
> (naming scheme in brackets)
> - Primary Key Constraints (PK_<TABLENAME><IDX>)
> - Unique Constraints
> - Check Constraints
> - Foreign Key Constraints
> <CT> for unique constraints is one of:
> - NN for Not Null Constraints
> - CK for other Check Constraints
> <IDX> is an index that is needed if the table or
> column name has to be shortened because of a maximal
> length of the constraint name in the database.
> At the moment, I have implemented it in the following way:
> - The constraint names are generated in the dialect.
> - Constraint naming can be turned on and off in the
> config file (persistence.xml).
> - Via the config file you can specify a character
> that is removed from the table and column names to
> improve the constraint name length utilization,
> e.g. COMPANY_DETAILS can be reduced to COMPANYDETAILS
> - The maximal constraint name length can be specified
> in the config file as well.
> That way, it is possible to identify the reason for a constraint
> violation much more easier. Additionally, you have not to be at the
> mercy of the database constraint naming schema.
> Is something similar implemented at the moment by anyone?
> I would be pleased if you like to add this functionality to the
> hibernate sources.
> In this case I would adapt my implementation:
> - Create an own class e.g. DefaultConstraintNamingStrategy,
> according to the table and column NamingStrategy ...
> - ... that can be overwritten and plugged in via the
> config file.
> What do you think about this idea?
> Best regards,
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: