SpringFuse has some built-in conventions. When these conventions are followed, SpringFuse generates cleaner Java code and some specific features. For example, if you want your users to upload some files through your web application, you can rely on SpringFuse to generate all the infrastructure code and configuration that will allow you to do it in an optimal way by simply following some columns naming convention.
'Camel Case' syntax is standard Java code convention. When SpringFuse encounters the character underscore '_' in a table’s name or a column’s name, it skips it and converts to upper case the next character when generating classes, variables or methods related to this table, or column.
If your table's and/or column's name use a camelCase syntax AND if the JDBC driver preserves this syntax, then SpringFuse takes it into account when generating classes, variables or methods related to this table, or column.
Choosing explicit names for your tables and columns is thus very important as it improves your source code readability.
![]() | Important |
|---|---|
| Each numerical primary key is configured in the Hibernate mapping file with '<generator class="native"/>'. 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), SpringFuse configures Hibernate to use an UUIDHexGenerator. Therefore no sequence is needed for these primary keys.
The Account table is a special table that contains the user's login and password columns and eventually the email and enabled columns. It has an important role during the login phase. It is also used by the AccountContext generated class which store the current account information in the current thread.
SpringFuse detects automatically your 'Account' table. An account table candidate is expected to have at least the following columns:
Table 4.1. Account table conditions
| Column's name | Mapped Java Type | Description |
|---|---|---|
| "username" OR "login" OR "user_name" OR "identifiant" | String | Login used by the end user to authenticate to this web application |
| "password" OR "pwd" OR "passwd" OR "mot_de_passe" OR "motdepasse" | String | Password (in clear) used by the end user to authenticate to this web application |
![]() | Note |
|---|---|
| If no Account table candidate is found, SpringFuse will do as if it had found one and will generate a mock Account DAO implementation that returns 2 dummy users (user/user and admin/admin) instead of generating an Hibernate DAO implementation. It is up to you to replace this DAO implementation with your own implementation. | |
The Role table is a special table that contains the account's roles. To be detected by SpringFuse, it must have a many-to-many relationship with the found 'Account' table and and contain the following mandatory column:
Table 4.2. Role table conditions
| Column's name | Mapped Java Type | Description |
|---|---|---|
| "authority" OR "name_locale" OR "role_name" OR "role" | String | The generated code relies on the following authority's values: "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" |
Here is a sample SQL script (H2 Database) that complies to SpringFuse conventions
CREATE TABLE ACCOUNT (
account_id char(32) not null, login
varchar(255) not null,
password varchar(255) not null,
email varchar(255) not null,
constraint account_unique_1 unique (login),
constraint account_unique_2 unique (email),
primary key (account_id) );
CREATE TABLE ROLE (
role_id smallint generated by default as identity,
name_locale varchar(255) not null,
constraint role_unique_1 unique (name_locale),
primary key (role_id) );
CREATE TABLE ACCOUNT_ROLE (
account_id char(32) not null,
role_id smallint not null,
constraint account_role_fk_1 foreign key (account_id) references ACCOUNT,
constraint account_role_fk_2 foreign key (role_id) references ROLE,
primary key (account_id, role_id) );
If the detected Account table has an email column, it is used by the generated code in few places, mostly as an illustration of the EmailService usage.
If the detected Account table has an enabled column, it is used by the generated code related to Spring Security integration.
When the following columns are present simultaneously in a table, SpringFuse generates various helper methods to ease file manipulation from the web tier to the persistence layer.
'prefix'_FILE_NAME (String)
'prefix'_CONTENT_TYPE (String)
'prefix_SIZE or 'prefix'_LENGTH (int)
'prefix'_BINARY (blob)
Example 4.3.
mydoc_content_type varchar(255) not null, mydoc_size integer not null, mydoc_file_name varchar(255) not null, mydoc_binary bytea,
This convention will allow you to upload a file transparently, save it to the corresponding table, then download it using a simple URL.
Whenever SpringFuse encounter a column name ending with '_LOCALE' it assumes that the columns is used to store a key for a localized property. The column type must naturally map to a java String (i.e database type of varchar). For such a column, SpringFuse generates a getter to retrieve directly the localized key’s value.
The locale used is retrieved from the Spring locale context.
![]() | Note |
|---|---|
| Make sure that the key used as a value in the 'xx_locale' column is also present in one of your properties file as a key with its* localized value. | |
Here is an example. You can add the TITLE_LOCALE column to your ACCOUNT table and fill it with either 'title.mister', 'title.miss' etc., SpringFuse will generate for you 2 additional methods in the AccountModel bean:
// returns the properties keys, stored in the database, for example: “title.mister” String titleKey = getTitleLocale(); // returns the value “Monsieur” assuming that in a properties file you // have defined for the French locale: // title.mister=Monsieur String titleValue = getTitleLocalized();
When a table contains a foreign key pointing to the Account table, SpringFuse 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 ContextInterceptor. Of course this default behavior may not always suit your needs. There are two ways of disabling it:
Disable the filter in the hibernate mapping file
Disable the filter programmatically using the HibernateFilterContext generated helper.
If your table has a column named VERSION whose type is an int, SpringFuse assumes by convention that you want to enable an optimistic locking strategy. As a result, the Hibernate mapping file generated by SpringFuse is configured by default to use this column for the optimistic locking strategy.