5

We are having a problem with ColdFusion 2018 and/or Hibernate 5.2.

We have a series of models for which DDL is generated without issue with ColdFusion 2016, but fails with ColdFusion 2018. We are not sure which (ColdFusion or Hibernate) is ultimately responsible for the issues we are seeing.

There are a few issues:

  • Database defaults no longer work
    • String defaults are no longer quoted properly.
    • This: property name="CompanyName" fieldtype="column" ormtype="string" default="Acme Inc." dbdefault="Acme Inc.";
    • Results in this statement in table create: CompanyName varchar(255) default Acme Inc. (missing quotes)
  • Database names are no longer quoted properly
    • We have databases named like "prefix.databasename" (with dot)
    • These used to work find but now in CF2018 results in errors such as "The object name 'prefix.databasename.dbo.SomeTable contains more than the maximum number of prefixes. The maximum is 2."
  • Table names are no longer quoted properly
    • Frustrating thing is that they are quoted properly sometimes and sometimes not. The following is taken from the hibernate logs: HIBERNATE DEBUG - alter table my_db.dbo.Group add DeletedByID int HIBERNATE DEBUG - alter table my_db.dbo.User add DeletedByID int HIBERNATE DEBUG - alter table [Group] add constraint FKfpa9ddoqu39xeskmmdg2pe3tq foreign key (DeletedByID) references [User] HIBERNATE DEBUG - alter table [User] add constraint FKj4hy4k4el0vvds8s8itfo2b04 foreign key (DeletedByID) references [User]
    • In the first two lines, notice that neither the database name nor the table name are quoted properly (causing the error "Error executing DDL via JDBC Statement - Incorrect syntax near the keyword 'Group'." as it chokes on the table name "Group"). However, in the next two lines it quotes the table names properly and doesn't qualify them with the database name...

I know somebody is going to weigh in and say that we shouldn't have dots in our table names and we shouldn't have tables named for keywords. Noted, but the bottom line is we do, have done so for years without issue and they are valid names when handled properly.

Has anybody else had similar problems? We're wondering if there is some new configuration setting that we are missing that control this behavior or if there is some other way to force ColdFusion/Hibernate to behave as it previously did. The alternative is to change the database and table names and go hunting through code for any direct references to the old names, but really, really don't want to do that.

Miguel-F
  • 13,450
  • 6
  • 38
  • 63
K. Meke
  • 433
  • 2
  • 14
  • I will be the one to weigh in about dots and reserved words. You are seeing the exact behavior that was the reason for it to initially be labelled a "bad idea", even if it did work for years before. Certain words and periods have meaning in databases. If fact, especially with the periods, you may be losing functionality that is built in to your db, and you are relying on your db connector to correctly translate your intent. `prefix.databasename.dbo.SomeTable` means to look in the `prefix` server, `databasename` database, `dbo` schema and `SomeTable` table. – Shawn Dec 19 '18 at 19:18
  • 1
    Likely CF2016 was possibly doing some sort of parameterization of the values it passed to Hibernate, so that it was able to escape certain reserved words, like `GROUP`, but it didn't escape `my_db.dbo.Group` since it didn't see the reserved word. Try escaping yourself. Put `[]` around your db and column names that should be escaped. (I'm assuming you are using SQL Server). – Shawn Dec 19 '18 at 19:18
  • Yeah, I was hoping that this is a known issue with a workaround. The bottom line is that it used to work and no longer does in CF2018. I can change every reference in my code to the tables and change all the DB names, but as I stated in my question, I would really prefer not to do so! I think I'm going to go ahead and start that process, but I was really hoping for a different answer... – K. Meke Dec 20 '18 at 19:31
  • I'm not sure if it's a known issue or not, but hit up the CF Slack or the Adobe Forums. If it ends up being a bug, report it. What database are you using? – Shawn Dec 20 '18 at 21:40
  • @Shawn, thx. We're using SQL Server 2014 and we have filed bugs with Adobe for the issues. – K. Meke Dec 21 '18 at 15:23

0 Answers0