Unknown Entity Error

I created an event schedule feature based on Pages which I’ve added to the admin panel under the content menu. I created the necessary table, model and handlers, views, etc. I’m getting the following error:

Error Type: org.hibernate.MappingException : 0
Error Messages: Unknown entity: cbeventSchedule

Help!

Did you reload ORM?

Yes

Can you post some code for your entity?

component persistent=“true” entityname=“cbeventSchedule” table=“cb_eventSchedule” batchsize=“25” cachename=“cbeventSchedule” cacheuse=“read-write” extends=“BaseContent” joinColumn=“contentID” discriminatorValue=“EventSchedule”{

// Properties
property name=“layout” notnull=“false” length=“200” default="";
property name=“mobileLayout” notnull=“false” length=“200” default="";
property name=“order” notnull=“false” ormtype=“integer” default=“0” dbdefault=“0”;
property name=“showInMenu” notnull=“false” ormtype=“boolean” default=“false” dbdefault=“0” index=“idx_showInMenu”;
property name=“eventDate” notnull=“true” ormtype=“timestamp” idx=“idx_EventDate”;
property name=“eventLocationName” notnull=“true” length=“200” default="";
property name=“eventLocationAddress” notnull=“true” length=“200” default="";
property name=“eventLocationCityStateZip” notnull=“true” length=“200” default="";
property name=“eventUniform” notnull=“true” length=“200” default="";
property name=“eventDirectionsLink” notnull=“true” length=“1000” default="";
property name=“eventArrivalTime” notnull=“true” ormtype=“timestamp”;
/************************************** CONSTRUCTOR *********************************************/

/**

  • constructor
    */
    function init(){
    customFields = [];
    renderedContent = “”;
    allowComments = false;
    createdDate = now();
    layout = “pages”;
    mobileLayout = “”;
    contentType = “EventSchedule”;
    eventDate = now();
    eventArrivalTime = now();
    eventLocationName = “”;
    eventLocationAddress = “”;
    eventLocationCityStateZip = “”;
    eventUniform “”;
    eventDirectionsLink = “”;

// INHERITANCE LAYOUT STATIC
LAYOUT_INHERITANCE_KEY = “-inherit-”;
}

/************************************** PUBLIC *********************************************/

/**

  • Get the layout or if empty the default convention of “pages”
    */
    function getLayoutWithDefault(){
    if( len(getLayout()) ){ return getLayout(); }
    return “pages”;
    }

/**

  • Get layout with layout inheritance, if none found return normal saved layout
    */
    function getLayoutWithInheritance(){
    var thisLayout = getLayout();
    // check for inheritance and parent?
    if( thisLayout eq LAYOUT_INHERITANCE_KEY AND hasParent() ){
    return getParent().getLayoutWithInheritance();
    }
    // Else return the layout
    return thisLayout;
    }

/**

  • Get mobile layout with layout inheritance, if none found return normal saved layout
    */
    function getMobileLayoutWithInheritance(){
    var thisLayout = ( isNull( mobileLayout ) ? ‘’ : mobileLayout );
    // check for inheritance and parent?
    if( thisLayout eq LAYOUT_INHERITANCE_KEY AND hasParent() ){
    return getParent().getMobileLayoutWithInheritance();
    }
    // Is the mobile layout none, then return the normal layout
    return ( !len( thisLayout ) ? getLayoutWithInheritance() : thisLayout );
    }

/**

  • Wipe primary key, and descendant keys, and prepare for cloning of entire hierarchies
  • @author.hint The author doing the cloning
  • @original.hint The original content object that will be cloned into this content object
  • @originalService.hint The ContentBox content service object
  • @publish.hint Publish pages or leave as drafts
  • @originalSlugRoot.hint The original slug that will be replaced in all cloned content
  • @newSlugRoot.hint The new slug root that will be replaced in all cloned content
    */
    BaseContent function prepareForClone(required any author,
    required any original,
    required any originalService,
    required boolean publish,
    required any originalSlugRoot,
    required any newSlugRoot){
    setLayout( original.getLayout() );
    return super.prepareForClone(argumentCollection=arguments);
    }

/*

  • Validate page, returns an array of error or no messages
    */
    array function validate(){
    var errors = [];

// limits
HTMLKeyWords = left(HTMLKeywords,160);
HTMLDescription = left(HTMLDescription,160);
passwordProtection = left(passwordProtection,100);
title = left(title,200);
slug = left(slug,200);
eventDate = eventDate;
eventArrivalTime = eventArrivalTime;
eventUniform = left(eventUniform(200));
eventLocationName = left(eventLocationName(200));

// Required
if( !len(title) ){ arrayAppend(errors, “Title is required”); }
if( !len(layout) ){ arrayAppend(errors, “Layout is required”); }

return errors;
}

Anybody?

Robert
I tried with another entity and it worked for me but I had to scope out the entire path to base content:

contentbox.model.content.BaseContent

However I see you reuse much of the page object as well, so why don’t you just inherit from page instead.

Luis

This is my first time working with ORM so I figured I’d create my own objects based on an existing one. So that why you see so much of the page stuff in there. Most of that will come out eventually once i have a good understanding of how this works. I did as you suggested, scoping out the entire path, but I’m still getting the error. Here is the error

Application Execution ExceptionError Type: org.hibernate.MappingException : 0

Error Messages: Unknown entity: cbeventSchedule

Tag Context:
ID: ??
LINE: 210
Template: /Users/RC Home/Documents/workspace/rc-cb-core/WebContent/coldbox/system/orm/hibernate/CriteriaBuilder.cfc
ID: ??
LINE: 119
Template: /Users/RC Home/Documents/workspace/rc-cb-core/WebContent/modules/contentbox/model/content/EventScheduleService.cfc
ID: ??
LINE: 69
Template: /Users/RC Home/Documents/workspace/rc-cb-core/WebContent/modules/contentbox-admin/handlers/EventSchedules.cfc
ID: ??
LINE: 753
Template: /Users/RC Home/Documents/workspace/rc-cb-core/WebContent/coldbox/system/web/Controller.cfc
ID: ??
LINE: 637
Template: /Users/RC Home/Documents/workspace/rc-cb-core/WebContent/coldbox/system/web/Controller.cfc
ID: ??
LINE: 236
Template: /Users/RC Home/Documents/workspace/rc-cb-core/WebContent/coldbox/system/Coldbox.cfc
ID: ??
LINE: 103
Template: /Users/RC Home/Documents/workspace/rc-cb-core/WebContent/Application.cfc

Anybody?

So a couple things to check off:

  • Have you updated Application.cfc, this.ormSettings.dbcreate to be “update”, or did you run a SQL script to create the new table and columns?
  • If so, did you reload ORM so that the updates would be run/CF would recognize the new entity?
  • Did a new table called “cb_eventSchedule” get created in your contentbox db?
    If the answer is no on any of these (especially the last one), it’s possible you have an error in your entity that CF is just skipping because of the skipCFCWithError setting in Application.cfc.

For example, I notice that there is at least one error in the init() method (missing “=”) sign on eventUniform “”; I don’t know if the actual code from your app, but when I tried to implement your changes to test the issue, that was the first issue I had to get around.

Hope this helps.

Thanks for responding joel. Here is what I have so far:

Application.cfc has the dbcreate set to update, but I did manually create the table and columns.
Yes, I have reloaded ORM several times but still get the same error.
the table name is cb_eventSchedule.

I also corrected the error you pointed out in the init method reloaded the app, ORM and still get the same error.

Turn off error skipping in the app.cfc and see if there is some other error.

That did uncover several other errors in the entity template. I’m worked through those and am at least at the point where it is recognizing the entity and loading its editor in the admin. Stay tuned :). Thanks!