Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Do that at compile time: sounds like job for maven <a href="http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html" rel="nofollow">filters</a> and/or <a href="http://maven.apache.org/guides/introduction/introduction-to-profiles.html" rel="nofollow">profiles</a> </p> <p>NOTE: be carefull with liquibase and any "marker" replacements... liquibase stores CRC of applied changessets</p> <p>pom.xml</p> <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;groupId&gt;test&lt;/groupId&gt; &lt;artifactId&gt;test&lt;/artifactId&gt; &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt; &lt;build&gt; &lt;filters&gt; &lt;filter&gt;src/main/filters/liquibase.properties&lt;/filter&gt; &lt;/filters&gt; &lt;resources&gt; &lt;resource&gt; &lt;directory&gt;src/main/resources&lt;/directory&gt; &lt;filtering&gt;true&lt;/filtering&gt; &lt;includes&gt; &lt;include&gt;liquibase.xml&lt;/include&gt; &lt;/includes&gt; &lt;/resource&gt; &lt;/resources&gt; &lt;/build&gt; &lt;/project&gt; </code></pre> <p>/src/main/filters/liquibase.properties</p> <pre><code>table.name=TABLE_NAME column1.name=COLUMN1_NAME column1.length=10 column2.name=COLUMN2_NAME </code></pre> <p>/src/main/resources/liquibase.xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt; &lt;databaseChangeLog logicalFilePath="liquibase.xml" 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-2.0.xsd"&gt; &lt;changeSet author="me" id="changeSetId1"&gt; &lt;comment&gt;Test&lt;/comment&gt; &lt;createTable tableName="${table.name}"&gt; &lt;column name="id" type="int" /&gt; &lt;column name="${column1.name}" type="varchar(${column1.length})" /&gt; &lt;column name="${column2.name}" type="int" /&gt; &lt;/createTable&gt; &lt;/changeSet&gt; &lt;/databaseChangeLog&gt; </code></pre> <p>EDIT: A <a href="http://www.liquibase.org/documentation/maven/" rel="nofollow">typical</a> invocation (using <a href="http://maven.apache.org/guides/getting-started/index.html#How_do_I_filter_resource_files" rel="nofollow">filtered</a> resources) would look like this: <code>mvn resources:resources liquibase:update</code> or more preferably use profiles... <code>mvn resources:resources liquibase:update -P&lt;profile_name&gt;</code></p> <p>EDIT2: There is one big advantage of this way of defining columns. You could use this property's (e.g.: column1.length) value (e.g.: 10) for validation of <b>every</b> layer: Hibernate, DAO, WEB, faces, JavaScript. Just use this property at each place where you need to validate against it. Even in i18n/messages.properties if needed (e.g.: input1.validation=No more than ${column1.length} letters.). </p> <p>The only complication is that if you need to change this value you need to provide proper liquibase update/rollback script. Sometimes it is possible to change value and set new liquibase checksum (safe operation like increase varchar length), but other times you need to create a <i>safe</i> update changescript using new property/value.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload