I have an addon “commons” with the user entity, all it’s ok in this addon (build, test,…)
@JmixEntity
@Table(name = "COM_USER", indexes = [
Index(name = "IDX_COM_USER_ON_USERNAME", columnList = "USERNAME", unique = true)
])
@Entity(name = "com_User")
open class User : BaseEntity(), JmixUserDetails, HasTimeZone {
@Column(name = "USERNAME", nullable = false)
@get:JvmName("getUsername_")
var username: String? = null
@Secret
@SystemLevel
@Column(name = "PASSWORD")
@get:JvmName("getPassword_")
var password: String? = null
@Column(name = "FIRST_NAME")
var firstName: String? = null
@Column(name = "LAST_NAME")
var lastName: String? = null
@Email
@Column(name = "EMAIL")
var email: String? = null
@Column(name = "ACTIVE")
var active: Boolean? = true
@Column(name = "TIME_ZONE_ID")
@get:JvmName("getTimeZoneId_")
var timeZoneId: String? = null
@Transient
protected var userAuthorities: Collection<GrantedAuthority?>? = null
override fun getPassword(): String? = password
override fun getUsername(): String? = username
override fun getAuthorities(): Collection<GrantedAuthority?> =
userAuthorities ?: emptyList()
override fun setAuthorities(authorities: Collection<GrantedAuthority?>) {
this.userAuthorities = authorities
}
override fun isAccountNonExpired(): Boolean = true
override fun isAccountNonLocked(): Boolean = true
override fun isCredentialsNonExpired(): Boolean = true
override fun isEnabled(): Boolean = active == true
@get:DependsOnProperties("firstName", "lastName", "username")
@get:InstanceName
val displayName: String
get() = "${firstName ?: ""} ${lastName ?: ""} [${username ?: ""}]".trim()
override fun getTimeZoneId(): String? {
return timeZoneId
}
}
and liquibase file
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
<changeSet id="1" author="commons-addon">
<createTable tableName="COM_USER">
<column name="ID" type="${uuid.type}">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="VERSION" type="int">
<constraints nullable="false"/>
</column>
<column name="USERNAME" type="varchar(255)">
<constraints nullable="false"/>
</column>
<column name="FIRST_NAME" type="varchar(255)"/>
<column name="LAST_NAME" type="varchar(255)"/>
<column name="PASSWORD" type="varchar(255)"/>
<column name="EMAIL" type="varchar(255)"/>
<column name="ACTIVE" type="boolean"/>
<column name="TIME_ZONE_ID" type="VARCHAR(255)"/>
<column name="CREATED_BY"
type="VARCHAR(255)"/>
<column name="CREATED_DATE"
type="DATETIME"/>
<column name="LAST_MODIFIED_BY"
type="VARCHAR(255)"/>
<column name="LAST_MODIFIED_DATE"
type="DATETIME"/>
</createTable>
</changeSet>
<changeSet id="2" author="commons-addon">
<createIndex indexName="IDX_COM_USER_ON_USERNAME"
tableName="COM_USER" unique="true">
<column name="USERNAME"/>
</createIndex>
</changeSet>
<changeSet id="3" author="commons-addon">
<insert tableName="COM_USER" dbms="postgresql, mssql, hsqldb">
<column name="ID" value="60885987-1b61-4247-94c7-dff348347f93"/>
<column name="VERSION" value="1"/>
<column name="USERNAME" value="admin"/>
<column name="PASSWORD" value="{noop}admin"/>
<column name="ACTIVE" valueBoolean="true"/>
</insert>
<insert tableName="COM_USER" dbms="oracle, mysql, mariadb">
<column name="ID" value="608859871b61424794c7dff348347f93"/>
<column name="VERSION" value="1"/>
<column name="USERNAME" value="admin"/>
<column name="PASSWORD" value="{noop}admin"/>
<column name="ACTIVE" valueBoolean="true"/>
</insert>
</changeSet>
<changeSet id="4" author="commons-addon">
<insert tableName="SEC_ROLE_ASSIGNMENT" dbms="postgresql, mssql, hsqldb">
<column name="ID" value="6c9e420a-2b7a-4c42-8654-a9027ee14083"/>
<column name="VERSION" value="1"/>
<column name="USERNAME" value="admin"/>
<column name="ROLE_CODE" value="system-full-access"/>
<column name="ROLE_TYPE" value="resource"/>
</insert>
<insert tableName="SEC_ROLE_ASSIGNMENT" dbms="oracle, mysql, mariadb">
<column name="ID" value="6c9e420a2b7a4c428654a9027ee14083"/>
<column name="VERSION" value="1"/>
<column name="USERNAME" value="admin"/>
<column name="ROLE_CODE" value="system-full-access"/>
<column name="ROLE_TYPE" value="resource"/>
</insert>
</changeSet>
</databaseChangeLog>
In another addon “address” which has “commons” has dependency.
I set the dependency in the addon-address.gradle
implementation("com.company.addon:addon-commons-starter:0.0.1-SNAPSHOT")
I add the Configuration (ComConfiguration) in the JmixModule dependsOn
@Configuration
@ComponentScan
@ConfigurationPropertiesScan
@JmixModule(dependsOn = [EclipselinkConfiguration::class, UiConfiguration::class, ComConfiguration::class])
@PropertySource(name = "com.company.addon.address", value = ["classpath:/com/company/addon/address/module.properties"])
open class AddConfiguration {…
and I set the liquibase in the changelog.xml
<include file="/com/company/addon/commons/liquibase/changelog.xml"/>
I get a liquibase error when I want generate the changelog
liquibase.exception.CommandExecutionException: java.lang.RuntimeException: Cannot map Java type to SQL/Liquibase type: java.util.Collection of com.company.addon.commons.entity.User#userAuthorities