.env
) with your database credentials and make sure that database exists:Application.cfc
and let's configure the ORM by adding the following in the pseudo constructor and adding two lines of code to the request start so when we reinit the APP we can also reinit the ORM..cfconfig.json
file. Once done, issue a server restart
and enjoy your new datasource name.Could not instantiate connection provider: org.lucee.extension.orm.hibernate.jdbc.ConnectionProviderImpl
error on startup here. It means that you hit the stupid Lucee bug where on first server start the ORM is not fully deployed. Just issue a server restart
to resolve this.coldbox create orm-entity
command:models/Person.cfc
as an ActiveEntity
object and even create the unit test for it./tests/Application.cfc
and add the following code to setup the ORM and some functions for helping us test.handlers/persons.cfc
with the CRUD actions and a nice index
action we will use to present all persons just for fun! /tests/specs/integration/personsTest.cfc
new()
method will allow you to pass a struct of properties and/or relationships to populate the new Person instance with. Then just call the save()
operation on the returned object.getMemento()
method come from? Well, it comes from the mementifier module wich inspects ORM entities and injects them with this function to allow you to produce raw state from entities. (Please see: https://forgebox.io/view/mementifier)get()
method which retrieves a single entity by identifier. Also note the default value of 0
used as well. This means that if the incoming id is null then pass a 0
. The ORM services will detect the 0
and by default give you a new Person object, the call will not fail. If you want your call to fail so you can show a nice exception for invalid identifiers you can use getOrFail()
instead.deleteById()
and pass in the identifierPerson
and render their memento'scborm
style!