[hibernate-issues] [Hibernate-JIRA] Closed: (HHH-3772) Constraint names cannot be quoted with backticks `
Steve Ebersole (JIRA)
noreply at atlassian.com
Fri Dec 4 19:38:08 EST 2009
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3772?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Steve Ebersole closed HHH-3772.
-------------------------------
Resolution: Duplicate
Not really "duplicate" but we don't really have a more appropriate resolution...
> Constraint names cannot be quoted with backticks `
> --------------------------------------------------
>
> Key: HHH-3772
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3772
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.3.1
> Environment: Hibernate 3.3, all database dialects
> Reporter: Christian
> Priority: Minor
>
> Table and Column names can be quoted with ` but constraint names cannot be quoted. You can reproduces the bug with the following testcase:
> @javax.persistence.Entity
> @javax.persistence.Table( name = "`categories`" )
> abstract public class Category {
> ...
> @org.hibernate.annotations.ForeignKey( name = "`fk_categories_parent_id`" )
> @javax.persistence.ManyToOne( targetEntity = Category.class )
> @javax.persistence.JoinColumn( name = "`parent_id`" )
> private Category parent;
> ...
> }
> The SchemaExport (hbm2ddl) creates the following SQL statement for Postgresql:
> alter table "categories" drop constraint `fk_categories_parent_id`;
> drop table "categories";
> create table "categories" (
> ...
> "parent_id" int8,
> ...
> );
> alter table "categories" add constraint `fk_categories_parent_id`
> foreign key ("parent_id") references "categories";
> I think this problem should be fixed in the method in the class org.hibernate.mapping.Constraint in the same way as in Table.java and Column.java:
> old:
> public void setName(String name) {
> this.name = name;
> }
>
> new:
> private boolean quoted = false;
> public void setName(String name) {
> if ( name.charAt( 0 ) == '`' ) {
> quoted = true;
> this.name = name.substring( 1, name.length() - 1 );
> }
> else {
> this.name = name;
> }
> }
> public String getQuotedName() .. same as in Column.java
> public String getQuotedName(Dialect d) { .. same as in Column.java
> public boolean isQuoted() .. same as in Column.java
> public String sqlDropString( ... ) {
> ...
> return "alter table " + getTable().getQualifiedName( dialect, defaultCatalog, defaultSchema ) + " drop constraint " + getQualifiedName();
> ...
> }
> public String sqlCreateString( ... ) {
> ...
> String constraintString = sqlConstraintString( dialect, getQualifiedName(), defaultCatalog, defaultSchema );
> ...
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list