Celerio has some built-in conventions. When these conventions are followed, Celerio generates some specific features.
For example, by simply following some columns naming convention, you can rely on Celerio to generate all the infrastructure code and configuration that will allow you to handle file upload and download in your web application, in an optimal way.
Each numerical primary key column is mapped with @GeneratedValue
and
@Id
annotations.
Important
If your database does not support identity columns, you should create the sequence
hibernate_sequence
. Please refer to Hibernate reference documentation for more advanced alternatives.
By convention, for all primary keys that are char(32)
, Celerio maps the
column with the following annotations
As it uses Hibernate’s UUIDHexGenerator
, no sequence is needed for these primary keys.
By convention, for all primary keys that are char(36)
, Celerio maps the
column with the following annotations
As it uses Hibernate’s UUIDGenerator
, no sequence is needed for these primary keys.
For primary key that are char(x)
where x is different from 32 or 36, Celerio
map the column with an assigned
generator, which means you must
provide manually the primary key value.
The generated UserDetailsServiceImpl
service is the link between the SpringSecurity’s world
and your user’s credential information. As you expect, this class must know how to
access the user’s login and password.
The generated implementation of this service varies depending on whether you follow or not Celerio’s conventions.
If your login credential are stored in your database, then you should make sure that the entity
playing the role of the account
entity has the properties expected by Celerio (e.g. login & password).
Once Celerio has found your account entity, it looks up the account entity’s many to many associations.
If it finds a many to many association whose target entity is also playing the role
of a Role
entity (e.g. it has an ‘authority’ property), then it uses it.
Note
The ‘Account’ and the ‘Role’ entities do not need to be named Account and Role.
By convention, Celerio considers that an entity is the Account
entity if it has the following properties:
Expected property | Type | Required? | Description |
---|---|---|---|
username, login, userName, identifiant, email, emailAddress, mail | String | Yes | Login used by the end user to authenticate to this web application |
password, pwd, passwd, motDePasse | String | Yes | Password (in clear) used by the end user to authenticate to this web application |
enabled, isEnabled | Boolean | No | Only enabled users (enabled == true) can login. |
Bear in mind that you can match this convention using Celerio configuration. Let’s assume that your users’ credentials are stored in a table named User that has 2 columns user_login and user_password.
Such a table would not be considered by default as the account table.
To have Celerio consider this table as the account table, you must map the user_login and user_password to one of the expected properties, for example:
Note
If no
Account
entity is found, theUserDetailsServiceImpl
simply returns hard coded users and roles.
By convention, Celerio considers that an entity is the Role
entity if it has the following property:
Expected property | Type | Required | Description |
---|---|---|---|
authority, roleName, role, nameLocale | String | Yes | The role name for example: ROLE_USER, ROLE_ADMIN |
By default, the configuration file generated by Celerio expects the content of the ‘authority’ column (or one of its variants) to match one of these role names:
This is just a convention coming from Security’s official documentation, if it does not suit your needs, you can change it manually in the files that uses these role names.
Here is a sample SQL script (H2 Database) that complies to Celerio conventions
When a table contains a foreign key pointing to the Account
table,
Celerio assumes that the content of this table belongs to the user
represented by the account_id
foreign key.
An hibernate filter is configured to make sure that this table is loaded only by the current user.
The filter is enabled by the HibernateFilterInterceptor
. Of course
this default behavior may not always suit your needs. There are two ways
of disabling it:
Remove the @Filter
annotation from the Entity. This imply taking
control over the entity.
Disable the filter programmatically using the HibernateFilterContext generated helper.
Disable globally this convention in Celerio’s configuration file.
If your table has a column named VERSION
whose type is compatible with the JPA @Version
annotation,
then by convention Celerio assumes that you want to enable an optimistic locking strategy.
As a result, the corresponding property is annotated with @Version
.
You can disable this convention in the configuration using columnConfig’s version attribute.
Which side of the @ManyToMany relation is marked as inverse="true"
?
By convention, the side whose corresponding column’s order is the highest on the ‘middle table’. You can override this convention using the parent’s columnConfig’s ‘inverse’ attribute.
When the following properties are present simultaneously in an entity, Celerio generates various helper methods to ease file manipulation from the web tier to the persistence layer.
Properties | Type | Description |
---|---|---|
prefixFileName | Boolean | File name |
prefixSize or prefixLength or prefixContentLength | Int | Length of the binary |
prefixContentType | String | Content type of the file |
prefixBinary or prefixContent or prefixBlob | Blob | Binary content of the file |
Example: Here is the corresponding SQL code using mydoc
as a prefix
With the column names above, the property names calculated by convention by Celerio match exactly the properties required to activate the file upload/download feature.
This convention allows you to upload a file transparently, save it to the corresponding table, then download it using a simple URL.
For a given entity, it is often desirable to know:
With JPA this feature can be implemented using @PreUpdate
and @PrePersist
annotations in the entity itself.
By convention, Celerio activates this feature if any of the following properties is present in an entity.
Description | Type | Required properties |
---|---|---|
Creation author | String | creationAuthor or creationBy or creePar |
Creation date | Date | creationDate or dateCreation |
Last modification author | String | lastModificationAuthor or lastModificationAt or derniereModificationPar or modifiePar |
Last modification date | Date | lastModificationDate or dateDerniereModification or derniereModification |
Example:
With the column names above, the property names calculated by convention by Celerio match exactly the properties required to activate the entity auditing feature.
In case your column names are slightly different, you can set the fieldName
attribute in the corresponding
column’s columnConfig, and the feature will be activated. For example:
Here is how looks the Java code in the corresponding entity:
The simple auditing feature allows you to track for each entity creation/modifications/deletion events and store them in a dedicated table. More generally this feature allow you to save any relevant event.
The audit log is stored in a single table. Its implementation uses JPA listeners.
This feature is simple in the sense that it does not rely on a framework such as Envers, which can be complex to apprehend. Instead, the implementation is simple and probably satisfactory for 90% of the cases.
By convention, Celerio generates the source code that implements this feature if the following conditions are met:
An audit entity must be present. Its name must be either:
This audit entity must have the following properties:
Required properties | Type | Description |
---|---|---|
author, auteur | String | Author |
event | String | Event type |
stringAttribute1, attribute1, string1 | String | First attribute |
stringAttribute2, attribute2, string2 | String | Second attribute |
stringAttribute3, attribute3, string3 | String | Third attribute |
For entity related event:
- event is either Creation, Modification, Deletion
- First attribute is used to store the entity name
- Second attribute is used to store the entity id
- Third attribute is used to store a description of the modifications
SQL Example:
With the column names above, the property names calculated by convention by Celerio match exactly the properties required to activate the simple database auditing feature.
In case your column names are slightly different, you can set the fieldName attribute in the corresponding column’s columnConfig, and the feature will be activated. For example:
When the following columns are present simultaneously in a table, Celerio will use these columns to propose the user to save its searches
The table should be called either saved_search
or saved_search_form
The table should contain the following columns
Property | Type | Description |
---|---|---|
formClass, formClassname | String | Fully qualified name of the search form type |
name | String | Name given to the saved search |
formContent | byte[] | Serialized form of the search |
accountId | String | FK linked to Account (not required) |
Example:
© 2005-2015 Jaxio | @jaxiosoft | Legal