A basic model for "social kernel" database and back-end, to be implemented with relational-JSON persistence (PostgreSQL 9.6+) and Java Spring-Boot framework... Testing limits of the Object-Relational mapping, semantic mapping, and showing best practices.
It is a simple model of an usual database: a person+organization contact catalogue (the core of any CRM)... With precise information and a RDF semantic. The basic entities are defined in SchemaOrg:
-
Organization: any sc:Organization with a name and a valid sc:vatID.
-
Agent: a generalization of Person and Organization (the union of both), as "formal person" (wd:legal person and wd:natural person). See foaf:Agent definition.
-
TeleCom: information about (stable) telecommunication-sc:ContactPoint of an Agent. Telephone, e-mail, homepage, etc. addresses.
Expanding: see Place and Agent-Agent relationships at SocKer-complete project, less didactic model but near to practical use.
To implement this model with good Java and good SQL,
And used as starting point (compatible) for SocKer-complete project.
The aim is to obtain both, good Java and good SQL.
-
Try with Spring Roo base-dbre (reverse engineer), usign step1.sql as reference... Is ok?
-
Try with full construction by Spring Roo (as samples do)... Is Ok?
-
Try "by hand" Spring Boot development.
Supposing a prepared env with PostgreSQL, Roo1 and Roo2, the first step is to obtain a sample of the database, defined in step1.sql:
cd ~
git clone https://github.com/ppKrauss/socKer.git
cd socKer
psql -h localhost -U postgres postgres < step1.sql
Using Roo1 as command roo
and the project's folder /roo1try1, to try method-1:
cd roo1try1
roo < step1.roo
As another Roo1 projects, need to edit conection, eg. with nano src/main/resources/META-INF/spring/database.properties
adding the lines of spring.jpa
,
spring.jpa.hibernate.naming.strategy=org.hibernate.cfg.ImprovedNamingStrategy
spring.jpa.hibernate.ddl-auto=create-drop
To test and log the database introspection, run roo < step2.roo > logIntrospect.txt
... Where we can see the first problem with Roo1, that not recognizes the commom sequences of IDs in the tables person and organization (see socker.agent_id_seq
at database). We will try to correct this problem "by hand" later, let's check what Roo1 can do with all schema with database reverse engineer
command in step3,
roo < step3.roo > step3.log
...
...
See all dumps at DUMPs folder.