Copy link to clipboard
Copied
Recently we started upgrading ColdFusion from 2016 to 2021.
So tried to install ColdFusion 2021 and using 30 days free trial for testing purpose
Application can’t make Database Calls so can’t able to login into application and can’t perform CURD operations.
Below are orm settings in application.
ormenabled = true;
ormsettings = {};
ormsettings.cfclocation = [… ];
ormSettings.dbcreate = "update";
ormSettings.flushAtRequestEnd = false;
ormsettings.eventhandling = true;
ormSettings.automanageSession = false;
ormSettings.savemapping = false;
ormSettings.skipCFCwitherror = false;
ormSettings.useDBforMapping = true;
ormSettings.autogenmap = true;
ormSettings.logsql = true;
And below are some errors on Hibernate level.
- Error executing DDL via JDBC Statement
Getting this error when adding new properties on entities like case, group. Because those are reserved words in database
Tried below options to resolve this issue but none helpful.
Adding hibernate properites as jvm arguments, orm properties, and created hibernate.cfg.xml file
hibernate.globally_quoted_identifiers
hibernate.auto_quote_keyword
hibernate.globally_quoted_identifiers_skip_column_definitions
[Found]
https://hibernate.atlassian.net/browse/HHH-12192
Suggesting to upgrade hibernate-core version 5.2.13
- org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
Getting this error on calling ormFlush();
[Found]
https://hibernate.atlassian.net/browse/HHH-12878
Suggesting to upgrade hibernate-core version 5.4.1
so is there any possibility for updating hibernate jars in ColdFusion 2021?
Or other possibilities to fix all those issues?
1 Correct answer
just found that i am always getting update logs
entitySave(Obj,true) is need for me to call explicitly to called
entitySave(obj) always updates me.
this is the fix for my application.
Many Thanks for all who tried to reach me out.
Copy link to clipboard
Copied
@SKKB : ... so is there any possibility for updating hibernate jars in ColdFusion 2021?
Don't!
Use the Hibernate that ships with ColdFusion (v5.2). It has been extensively tested and optimized for use in ColdFusion.
> ... Application can’t make Database Calls so can’t able to login into application and
> can’t perform CURD operations.
That is probably because you have not yet created a datasource for Hibernate to use.
Go to the datasource page in the ColdFusion Administrator. If you haven't done so yet, create a datasource which Hibernate will use.
For example, my datasource is called cfTest_db. The relevant settings in my Application.cfc file are:
this.datasource="cfTest_db";
this.ormSettings.dialect = "MySQL";
Copy link to clipboard
Copied
@BKBK Thanks
I have datasource configured.
for testing purpose we have careated new DB, there hibernate creates all entities > Tables created on first invoke. Then it started throwing error on calling ormFlush();
then i updated ormFlush() to ormFlush(ORMGetSession());
then i can able to passon to login screen without errors.
but application can't able to login.
and i didn't see any error log, when i check log files.
that was the blocker for my setup process in CF2021.
Copy link to clipboard
Copied
Then it started throwing error on calling ormFlush();
then i updated ormFlush() to ormFlush(ORMGetSession());
By SKKB
Do you have similar settings to the ones I suggested in my last post? That is:
this.datasource="cfTest_db";
this.ormSettings.dialect = "MySQL";
If so, then it will be sufficient to use: ormFlush();
Alternatively, you could use: ormFlush(your_datasource_name);
But, as far as I know, the following is wrong: ormFlush(ORMGetSession());
The log file to pay attention to is: hibernatesql.log
Copy link to clipboard
Copied
Thanks @BKBK
we are happy to getting your though process on this issue and glad we are on same direction.
As per API ormFlush(your_datasource_name); is the write.
but i did this change intentionally ormFlush(ORMGetSession());
so that i can look any other errors, instead i got a clean pass that's weird.
i don't know how coldfusion behaves on that.
when i look into hibernatesql.log, i do see all select and update queries to my application.
and i didn't see any error log.
so that's where we block our application setup in ColdFusion 2021 server.
if i flip it back to original ormFlush() i am getting same error as below.
org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
if we are able to fix it then below change wont be necessary.
ormFlush(ORMGetSession())
Copy link to clipboard
Copied
if i flip it back to original ormFlush() i am getting same error as below.
org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
By SKKB
ColdFusion is weakly-typed. Weird things may pass without error. Though you get no errors with ormFlush(ORMGetSession()), that doesn't mean it is correct. Something very simple might be happening. For example, no flushing at all. No flushing means no exception.
I would stay with ormFlush(), as it is the correct way to do it. Pay attention to the exception. It is telling you something.
The exception says "row count from update:0 actual row count: 0 expected: 1". What this implies is: there were no changes made in any of the entities in the current ORM session. That is something you should know, rather than suppress.
If you want to avoid the exception, then do an update before the flush. Something like:
<!--- The entity update will ensure that at least 1 row will be flushed --->
<cfset employee = entityLoad('employee', 100, true)>
<cfset employee.setLastName("Smith")>
<cfset entitySave(employee)>
<cfset ormFlush()>
Copy link to clipboard
Copied
Copy link to clipboard
Copied
OK. What happens when you enclose every ORM save or update within a transaction?
Something like:
transaction {
entitySave(employee);
}
Copy link to clipboard
Copied
Another example using transactions:
<cftransaction>
<cfset account1 = entityLoad("Account", "123")>
<cfset account2 = entityLoad("Account", "789")>
<cfset account1.debit(1000)>
<cfset account2.credit(1000)>
<cfset entitySave(account1)>
<cfset entitySave(account2)>
</cftransaction>
You will find the reason for my suggestion in https://helpx.adobe.com/coldfusion/using/whats-new-coldfusion-2018.html . Scroll to the section "Hibernate Upgrade". There you will read,
"You must update an entity inside a transaction."
Copy link to clipboard
Copied
Thanks @BKBK
Tried the same long back, but didn't work for me
ormFlush(ORMGetSession()) is misleading so didn't catch the actual issue.
With extensive Debug on application found that,
Entity updates is causing the issue.
when application loading there some entity updates causing issue
as ORM can't able to do that, i did them manually while debugging and it passes me to log-in successfully.
so Transaction management is causing the issue.
coincidently found the same update form you.
​​​Anyway thanks for your efforts on this issue.
So working on how to fix it in my applicaiton. 🙂
Copy link to clipboard
Copied
If you shared the code, we could look at it together. If it contains sensitive information, send it to me by private-message.
Copy link to clipboard
Copied
@BKBK i am back
what i found is,
i can update existing db record with or without transaction , but can't save new records.
On saving new records i am getting this error.
org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
Ex:1
<cfset account1 = entityLoad("Account", "123")>
<cfset account2 = entityLoad("Account", "789")>
<cfset account1.debit(1000)>
<cfset account2.credit(1000)>
<cfset entitySave(account1)>
<cfset entitySave(account2)>
It works without mentioning transaction explicitly.
Ex: 2
<cfset accountObj = entityNew("Account")>
<cfset entitySave(accountObj)>
the above code throws below error and not working with/without Transaction.
org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
i got struk here again.
Note: i am using UUID auto generator for ID's
Copy link to clipboard
Copied
just found that i am always getting update logs
entitySave(Obj,true) is need for me to call explicitly to called
entitySave(obj) always updates me.
this is the fix for my application.
Many Thanks for all who tried to reach me out.
Copy link to clipboard
Copied
Thanks for sharing your findings.

