java - FindBugs: How to avoid "Unwritten public field" warning when using JPA meta model? -
i've written quite lot of dao class , using jpa criteria api , meta model in them, in example:
@override public entitya findbyentityb(entityb entityb) { criteriabuilder builder = this.getcriteriabuilder(); criteriaquery<entitya> criteriaquery = builder.createquery(entitya.class); root<entitya> root = criteriaquery.from(entitya.class); criteriaquery.select(root); criteriaquery.where(builder.and(builder.equal(root.get(entitya_.entityb), entityb))); return this.findbycriteriaquery(criteriaquery); } while running static code analysis, findbugs throws following warning:
uwf_unwritten_public_or_protected_field, priorität: normal
unwritten public or protected field: entitya_.entityb
no writes seen public/protected field. reads of return default value. check errors (should have been initialized?), or remove if useless.
as use meta model classes in of queries warning thrown often.
is there useful way avoid these warnings? know meta model classes generated , attributs never written.
i don't want exclude dao classes findbugs sca want check these maybe find other possible bugs!
here ideas:
- modify generator add (redundant) setter.
- implement findbugs filter (see http://findbugs.sourceforge.net/manual/filter.html) exclude specific bug in specific classes or packages. or generally.
Comments
Post a Comment