Database/Model mapping

Hello. Can anyone help me get started with understanding how models and databases interact? There does not seem to be any sort of documentation on the subject. I can see roughly how models are defined in domains/ModelName.xml files, but, looking at existing models, it is clear that a number of fields which appear in the database schema, e.g. « id », « updated_on » etc have no apparent mapping in these files. I am guessing that these are standard fields which are defined/configured somewhere else. Is this something I will understand when I learn how Hibernate works? Do I have to run some sort of procedure (possibly some sort of gradle command) which will take the xml file and effect the necessary updates to the database schema, or do I have to make the schema updates manually?
I am used to working in PHP/MVC environments, which use database « migrations » to effect schema changes, and clearly Axelor/Java/Hibernate uses a totally different procedure which I know nothing about, so any help to get me started would be appreciated.

welcome, let me explain a few of them.

Domains are defined as xml you can consider as model layer in MVC, they are extended to audit model which is defined in adk, which is separate project named axelor open platform, and we don’t have to learn complex hibernate etc ( even though it is good practice to learn these), and it has really nice feature to track changes by just writing fields in domains under track section <track> importantColToTrack </track>

once you update domain xml file while development you have to run ./gradlew generateCode to have updated schema file in build folder to help in IDE

and once you run ./gradlew run command, it scans all domain xml files, create database tables and update tables with only new columns

and yes it have migrations from flyway module, put migration scripts in src/main/resources/db/migration under root folder than following command to apply migration ./gradlew database --migrate

and if you are new to java start with kotlin, it is more linked with php :-), might be i am wrong but i saw it helps in fast development like php, java is very strict in data types,

axelor works well equally with kotlin, you can develop new modules very easily

best way to start with axelor/open platform demo, it has wealth of information

Write all models in domains under resources folder, controllers in web folder under java/main, and create services to be called from controller or directly via cron jobs (it has very great scheduler too), views are mostly xml files under resources/view folders, by the folder names not matter xml file content matters

axelor truly help to focus on application development and care for rest
wish you good luck

3 J'aime

Thankyou, Siddique; that is some useful information to be going on with. Regards, Tom

and one thing related to migration, you have to create this before migration can start, it is baseline table

CREATE TABLE public.schema_version ( installed_rank int4 NOT NULL, "version" varchar(50) NULL, description varchar(200) NOT NULL, "type" varchar(20) NOT NULL, script varchar(1000) NOT NULL, checksum int4 NULL, installed_by varchar(100) NOT NULL, installed_on timestamp NOT NULL DEFAULT now(), execution_time int4 NOT NULL, success bool NOT NULL, CONSTRAINT schema_version_pk PRIMARY KEY (installed_rank) ); CREATE INDEX schema_version_s_idx ON public.schema_version USING btree (success);

explained it in detail here

1 J'aime