After having changed a value in the Film Editor, if you try to save your change into the database, an error occurs:
This error is caused by a inaccurate mapping of the special type year of the column “release_year” in the table Film of the mysql database.
release_year year(4)is mapped in:
private Date releaseYear;
In order to fix the problem, you must apply these 4 changes:
Update
private Date releaseYear;
...
@Temporal(TemporalType.DATE)
@Column(name="release_year", length=0)
public Date getReleaseYear() {
return this.releaseYear;
}
public void setReleaseYear(Date releaseYear) {
this.releaseYear = releaseYear;
}
by
private Date releaseYear;
...
@Temporal(TemporalType.DATE)
@Column(name="release_year", length=0)
public Date getReleaseYear() {
return this.releaseYear;
}
public void setReleaseYear(Date releaseYear) {
this.releaseYear = releaseYear;
}
Regenerate EJB is you use a application server.
Update
<dateText property="releaseYear" style="SWT.BORDER | AdiSWT.DELETE_BUTTON" id="releaseYear"/>
by
<formattedText editPattern="####" format="Integer" property="releaseYear" id="releaseYear">
<validators>
<validator key="invalidYear" errorMessage="#MSG(film, invalid.year.value, #FV())">
<errorWhen>return #FV() < 1900 || #FV() > 2155;</errorWhen>
</validator>
</validators>
</formattedText>
Update
<tableColumn property="releaseYear" sorted="true" id="releaseYearTC"/>
by
<tableColumn property="releaseYear" pattern="#####" sorted="true" id="releaseYearTC"/>
add line:
invalid.year.value = Invalid year '{0}'! Value must be between 1900 and 2155
By modifying the Scenario.xml file as follows, you force the automatic generation process to include changes described above.
Update
<pluginEntity entityURI="adi://myproject/model.film/FilmMM">
<generationUnit adiResourceURI="adi://model.film/FilmMM" type="ENTITY"/>
<generationUnit adiResourceURI="adi://model.film/FilmQUERY" type="QUERY"/>
<generationUnit adiResourceURI="adi://model.film/FilmDI" type="DETAIL"/>
<generationUnit adiResourceURI="adi://./film" type="MESSAGE_BUNDLE"/>
<generationUnit adiResourceURI="adi://model.film/FilmEDITOR" type="EDITOR"/>
<generationUnit adiResourceURI="adi://model.film/FilmTI" type="TABLE"/>
</pluginEntity>
by
<pluginEntity entityURI="adi://././FilmMM">
<generationUnit adiResourceURI="adi://model.film/FilmMM" type="ENTITY"/>
<generationUnit adiResourceURI="adi://model.film/FilmQUERY" type="QUERY"/>
<generationUnit adiResourceURI="adi://model.film/FilmDI" type="DETAIL"/>
<generationUnit adiResourceURI="adi://./film" type="MESSAGE_BUNDLE"/>
<generationUnit adiResourceURI="adi://model.film/FilmEDITOR" type="EDITOR"/>
<generationUnit adiResourceURI="adi://model.film/FilmTI" type="TABLE"/>
<messages>
<message key="invalid.year.value" value="Invalid year '{0}'! Value must be between 1900 and 2155"/>
</messages>
<propertyField id="releaseYear" pojoType="int">
<controlField xsi:type="formattedTextType" editPattern="####" format="Integer">
<validators>
<validator key="invalidYear" errorMessage="#MSG(film, invalid.year.value, #FV())">
<errorWhen>return #FV() < 1900 || #FV() > 2155;</errorWhen>
</validator>
</validators>
</controlField>
</propertyField>
</pluginEntity>
Each time, you decide to relaunch a generation process, these modifications will be made in appropriate files.
| Line 159: | add an item in FilmGENERATED.properties file. |
|---|---|
| Line 161: | Type for release_year is int. Change will automatically be made in the accurate pojo (fFilm.java). |
| Line 162: | The controller linked to release_year will be a FormattedText controller. |
| Lines 164-166: | Add a validator: value of the property must be between 1900 and 2155. |
These intended modifications can be stored in a customized Scenario Tree which will be merged to the standard Scenario Tree as shown in this page.