ORM query caching

Hi

It seems that ORM (Hibernate) is caching my queries when it’s doing entity loading.

For example if I try to load the following entity (userService.get(“xxx”)):

component persistent=“true” entityname=“User” table=“users” output=“false” {
property name=“id” column=“username” fieldtype=“id”;

property name=“location”
fieldtype=“many-to-one”
cfc=“Location”
fkcolumn=“location_id123”; // deliberate mistake

public User function init() output=“false” {
return this;
}
}

I’ll first get a SQL error “[Macromedia][SQLServer JDBC Driver][SQLServer]Invalid column name ‘location_id123’.”, which is fine, since the correct column name should be location_id.

But if I change the fkcolumn to location_id, I continue to get the exact same error ([Macromedia][SQLServer JDBC Driver][SQLServer]Invalid column name ‘location_id123’.), which indicates that the query is cached.

This is my ormSettings in Application.cfc:

this.ormSettings = {
// Location of your entities, default is your convention model folder
cfclocation = ["./model/entities"],
// Choose if you want ORM to create the database for you or not?
dbcreate = “none”,
// Log SQL or not
logSQL = true,
// Don’t flush at end of requests, let Active Entity manage it for you
flushAtRequestEnd = false,
// Don’t manage session, let Active Entity manage it for you
autoManageSession = false,
// Active ORM events
eventHandling = true,
// Use the ColdBox WireBox Handler for events
eventHandler = “coldbox.system.orm.hibernate.WBEventHandler”,
secondaryCacheEnabled = false,
flushatrequestend = true
};

Any idea what else should I try?

Thanks!

Hi,

I would suggest read about ormflush() … after saving the entity try ormflush()Flushes the current ORM session associated with the data source specified in the application. ORMFlush flushes all the pending CRUD operations in that request.

Tried that as well. Here’s the code:

ormClearSession();
ormFlush();

local.user = userService.get(“nick”);

There is no “saving” of entity at all for now - just testing the loading part.

So far I can only get around the query caching by restart ColdFusion, which sucks!!

Have you tried ormreload() to rebuild the orm mappings?

Yes!!! That works!!

Thanks Neil!