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
however these types of tools generally lead to an anemic domain model
(https://martinfowler.com/bliki/AnemicDomainModel.html) 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
(http://cfdocs.org/cfdbinfo) 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
(https://github.com/coldbox-modules/cbox-cborm 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.