Wednesday, 21 November 2012

itcrowd-domain-findbugs 1.0.0

We're tired for manual checking javax.validation annotations against entity's persistent properties. For all of you who feel the same we bring itcrowd-domain-findbugs.

What is so painful? Let's look at the example.
@Table(name = "SizeTestingEntity")
public class SizeTestingEntity {
// ------------------------------ FIELDS ------------------------------

    @Column(length = 34)
    private String invalidD;

    private String invalidE;

    @Size(max = 34)
    @Column(length = 34)
    private String validA;

    @Column(nullable = false)
    private String missingNotNull;

    @ManyToOne(optional = false)
    @JoinTable(name = "BLA", joinColumns = @JoinColumn(name = "ManyToOneEntity"), inverseJoinColumns = @JoinColumn(name = "joinTableD"))
    private Group joinTableD;

If we have @Column for attribute of type String it's good to specify @Size.
@Column with attribute "nullable=false" should be accompanied with  @NotNull or @NotEmpty annotation.
Other thing we have to keep synchronized is value of "optional" attribute of @ManyToOne against @NotNull.

There is also many other checks. Maintaining this manually is a nightmare, so we've written plugin for findbugs that does this automatically.
Right now there are following checks:
  • ForeignKeyInconsistency
  • NotNullInconsistency
  • NotEmptyInconsistency
  • SizeInconsistency
  • TableInconsistency
  • ManyToOneInconsistency
We plan to add more checks in future.


All you have to do is to configure findbugs to be aware of our plugin. Here is sample configuration of findbugs-maven-plugin:
Of course you have to add our artifactory to your maven settings.xml:
Downloads are available at our Artifactory : itcrowd-findbugs-domain-1.0.0.jar.
Sources are hosted at