Railo 3.2.2 ORM / Coldbox VirtualEntityService

I am having a weird problem.

I have a simple model called User and UserService.

Here is User.cfc

component persistent=“true” table=“USER” {

//Properties

property name=“userID” column=“USER_ID” hint=“The id for the User” fieldtype=“id” type=“numeric” datatype=“integer” generator=“identity” setter=“false”;

property name=“personID” column=“PERSON_ID”;

property name=“uuid” column=“UUID”;

property name=“dateLastLogin” column=“DATE_LAST_LOGIN”;

property name=“userAgent” column=“USER_AGENT”;

property name=“ipAddress” column=“IP_ADDRESS”;

}

Here is UserService.cfc

component extends=“coldbox.system.orm.hibernate.VirtualEntityService” singleton {

/**

  • Constructor
    */
    public userService function init(){

super.init(entityName=“user”);

return this;

}

}

Now the problem is that I am unable to get this to save data. I can only get it to insert a new record if it doesn’t exists. Any ideas on what could be wrong?

My code that inserts:

var userS = userService.new();
userS.setPersonID(1);
userService.save(userS);

My code that doesn’t update:

var userS = userService.get(3);
userS.setPersonID(2);
userService.save(userS);


Jeremy R. DeYoung
Phone: 615.261.8201

FacebookLinkedInGoogle ReaderTwitterAmazonGoogle
RantsFromAMadMan.com

it looks odd to me that in your update code you’re attempting to alter the primary key of the record…is that allowed??? I would think/hope not! What if you attempt to update a different field, like firstname or something? Does that still fail as well?

@Doug, if you read it carefully you will see that personId is not the primary key.

@Jeremy, what settings do you have in your application.cfc when it comes to the flush settings? And have you tried the flush argument of the save at all?

Regards,

Andrew Scott

http://www.andyscott.id.au/

Sorry for not being clear but my primary key is UserID and I am trying to update the foreign key of PersonID.


Jeremy R. DeYoung
Phone: 615.261.8201

FacebookLinkedInGoogle ReaderTwitterAmazonGoogle
RantsFromAMadMan.com

Andrew

i think the application.cfc is my problem

<cfset this.ormSettings = {

cfclocation=“model”,

dialect = “MySQLwithInnoDB”,

logSQL = true,

flushAtRequestEnd = false,

eventHandling = true,

eventHandler = “model.utilities.ORMEventHandler”

}>

I changed flushAtReqeustEnd to true - testing it now.


Jeremy R. DeYoung
Phone: 615.261.8201

FacebookLinkedInGoogle ReaderTwitterAmazonGoogle
RantsFromAMadMan.com

@Andrew & @Doug - that was my problem - so silly.


Jeremy R. DeYoung
Phone: 615.261.8201

FacebookLinkedInGoogle ReaderTwitterAmazonGoogle
RantsFromAMadMan.com