Can we convert a sql table to lucee (coldbox) model automatically?

Can we convert a sql table to lucee (coldbox) model automatically?

If you’re asking if Lucee (or Coldbox for that matter) can read your SQL
database and automatically generate beans, gateways, services, etc. for
you, then the answer is no.

There are tools out there that can do this sort of thing, such
as

however these types of tools generally lead to an anemic domain model
(AnemicDomainModel) situation and,
these days, are generally frowned upon.

That said, I myself, and many other developers I know, have written our own
tools that are fit for purpose and generate stub model code we can then use
as a basis for building a complete domain model. One can use
(cfdbinfo Code Examples and CFML Documentation) to get the table and column data, etc. and
then have have code that stubs out the beans, gateways, dao’s, services,
whathaveyou that you want to use as a beginning point. In either case, this
merely saves you some repetitive typing and will not build a complete
domain model for you.

You could also use ORM to achieve much of the same functionality with less
code and less typing, but it has it’s own set of issues. Since you’re in
ColdBox I would explore CBORM
(GitHub - coldbox-modules/cborm: The ColdBox ORM enhancements for ColdFusion ORM & Hibernate. Make ORM not suck! or box install cborm) as a
value add to ColdBox and ORM together, which smooths over some of the
ugliness of ORM. That said I don’t use ORM or CBORM myself, but I know
others that do and they swear by both.

Either way, building a complete and rich domain model for your database
simply requires effort. There is no magic bullet that will automatically do
this for you - only code that stubs out the basics and you can expand on
that as needed.

HTH

– Denny