| Currently if any column that is mapped by a component is non-null the component will be initialized. Feature: I would suggest to allow a column have an optional default value, and if the value equals the default value the component will be null. So even if column flag is not null but 0 the variable fooComp will still be null.
<component name="fooComp" class="package.FooComp">
<property name="name"/>
<property name="flag" default="0"/>
</component>
This makes it easier for other queries to check against flag or similar columns, since a cumbersome construct like COALESCE(flag, 0) = 1 is not required. Example: By default we make all our bit fields non-null, since null mostly indicates a three-way logic. We had a table foo with two columns we wanted to map to a composite:
test INT NOT NULL,
name VARCHAR(64) NULL,
flag BIT NOT NULL DEFAULT = 0
private int test;
private FooComp fooComp;
@NotBlank
private String name;
private boolean flag;
With the column flag being non nullable the component was always initialized, which was not desired. So we had to make it nullable, replicate default in queries using COALESCE(flag, 0) and add @NotNull to flag. |