Buggy code:
) public class OnmsHwEntity implements Serializable , Comparable < OnmsHwEntity > { private static final long serialVersionUID = - 543872118396806431L ; private Integer m_id ; private Integer m_entPhysicalIndex ; private Integer m_entPhysicalParentRelPos ; private Integer m_entPhysicalContainedIn ; private String m_entPhysicalName ; private String m_entPhysicalDescr ; private String m_entPhysicalAlias ; private String m_entPhysicalVendorType ; private String m_entPhysicalClass ; private String m_entPhysicalMfgName ; private String m_entPhysicalModelName ; private String m_entPhysicalHardwareRev ; private String m_entPhysicalFirmwareRev ; private String m_entPhysicalSoftwareRev ; private String m_entPhysicalSerialNum ; private String m_entPhysicalAssetID ; private Boolean m_entPhysicalIsFRU ; private Date m_entPhysicalMfgDate ; private String m_entPhysicalUris ; private OnmsNode m_node ; private SortedSet < OnmsHwEntityAttribute > m_hwAttributes = new TreeSet < OnmsHwEntityAttribute > ( ) ; private OnmsHwEntity m_parent ; private SortedSet < OnmsHwEntity > m_children = new TreeSet < OnmsHwEntity > ( ) ; public OnmsHwEntity ( ) { } @ Id @ Column ( nullable = false ) @ XmlTransient @ SequenceGenerator ( name = "opennmsSequence" , sequenceName = "opennmsNxtId" ) @ GeneratedValue ( generator = "opennmsSequence" ) public Integer getId ( ) { } public void setId ( Integer id ) { } @ XmlID @ XmlAttribute ( name = "entityId" ) @ Transient public String getOnmsHwEntityId ( ) { } public void setOnmsHwEntityId ( final String id ) { } @ Column ( nullable = false ) @ XmlAttribute public Integer getEntPhysicalIndex ( ) { } public void setEntPhysicalIndex ( Integer entPhysicalIndex ) { } @ Transient @ XmlTransient public Integer getEntPhysicalContainedIn ( ) { } public void setEntPhysicalContainedIn ( Integer entPhysicalContainedIn ) { } @ Column @ XmlElement public String getEntPhysicalDescr ( ) { } public void setEntPhysicalDescr ( String entPhysicalDescr ) { } @ Column @ XmlElement public String getEntPhysicalVendorType ( ) { } public void setEntPhysicalVendorType ( String entPhysicalVendorType ) { } @ Column @ XmlElement public String getEntPhysicalClass ( ) { } public void setEntPhysicalClass ( String entPhysicalClass ) { } @ Column @ XmlTransient public Integer getEntPhysicalParentRelPos ( ) { } public void setEntPhysicalParentRelPos ( Integer entPhysicalParentRelPos ) { } @ Column @ XmlElement public String getEntPhysicalName ( ) { } public void setEntPhysicalName ( String entPhysicalName ) { } @ Column @ XmlElement public String getEntPhysicalHardwareRev ( ) { } public void setEntPhysicalHardwareRev ( String entPhysicalHardwareRev ) { } @ Column @ XmlElement public String getEntPhysicalFirmwareRev ( ) { } public void setEntPhysicalFirmwareRev ( String entPhysicalFirmwareRev ) { } @ Column @ XmlElement public String getEntPhysicalSoftwareRev ( ) { } public void setEntPhysicalSoftwareRev ( String entPhysicalSoftwareRev ) { } @ Column @ XmlElement public String getEntPhysicalSerialNum ( ) { } public void setEntPhysicalSerialNum ( String entPhysicalSerialNum ) { } @ Column @ XmlElement public String getEntPhysicalMfgName ( ) { } public void setEntPhysicalMfgName ( String entPhysicalMfgName ) { } @ Column @ XmlElement public String getEntPhysicalModelName ( ) { } public void setEntPhysicalModelName ( String entPhysicalModelName ) { } @ Column @ XmlElement public String getEntPhysicalAlias ( ) { } public void setEntPhysicalAlias ( String entPhysicalAlias ) { } @ Column @ XmlElement public String getEntPhysicalAssetID ( ) { } public void setEntPhysicalAssetID ( String entPhysicalAssetID ) { } @ Column @ XmlElement public Boolean getEntPhysicalIsFRU ( ) { } public void setEntPhysicalIsFRU ( Boolean entPhysicalIsFRU ) { } @ Column @ XmlElement public Date getEntPhysicalMfgDate ( ) { } public void setEntPhysicalMfgDate ( Date entPhysicalMfgDate ) { } @ Column @ XmlElement public String getEntPhysicalUris ( ) { } public void setEntPhysicalUris ( String entPhysicalUris ) { } @ XmlTransient @ ManyToOne ( cascade = { CascadeType . ALL } , optional = true ) @ JoinColumn ( name = "parentId" ) public OnmsHwEntity getParent ( ) { } public void setParent ( OnmsHwEntity parent ) { } @ Transient @ XmlAttribute ( name = "parentPhysicalIndex" ) public Integer getParentIndex ( ) { } @ XmlElement ( name = "hwEntity" ) @ XmlElementWrapper ( name = "children" ) @ Sort ( type = SortType . NATURAL , comparator = OnmsHwEntity . class ) @ OneToMany ( mappedBy = "parent" , fetch = FetchType . LAZY , cascade = { CascadeType . ALL } ) public SortedSet < OnmsHwEntity > getChildren ( ) { } public void setChildren ( SortedSet < OnmsHwEntity > children ) { } public void addChildEntity ( OnmsHwEntity child ) { } public OnmsHwEntity getChildByIndex ( Integer entPhysicalIndex ) { } public void removeChild ( OnmsHwEntity child ) { } @ ManyToOne ( fetch = FetchType . LAZY ) @ JoinColumn ( name = "nodeId" ) @ XmlAttribute ( name = "nodeId" ) @ XmlJavaTypeAdapter ( NodeIdAdapter . class ) public OnmsNode getNode ( ) { } public void setNode ( OnmsNode node ) { } @ OneToMany ( mappedBy = "hwEntity" , fetch = FetchType . LAZY , cascade = { CascadeType . ALL } , orphanRemoval = true ) @ Sort ( type = SortType . NATURAL ) @ XmlElement ( name = "hwEntityAttribute" ) @ XmlElementWrapper ( name = "vendorAttributes" ) public SortedSet < OnmsHwEntityAttribute > getHwEntityAttributes ( ) { } public void setHwEntityAttributes ( SortedSet < OnmsHwEntityAttribute > hwAttributes ) { } public void addAttribute ( HwEntityAttributeType type , String value ) { } public OnmsHwEntityAttribute getAttribute ( String typeName ) { } public String getAttributeValue ( String typeName ) { } public String getAttributeClass ( String typeName ) { } @ Transient public boolean isRoot ( ) { <START_BUG> return ( ( m_parent ) == null ) || ( ( m_entPhysicalIndex ) == 0 ) ; <END_BUG> } @ Transient public boolean hasChildren ( ) { } @ Override public String toString ( ) { } @ Override public int hashCode ( ) { } @ Override public boolean equals ( Object obj ) { } @ Override public int compareTo ( OnmsHwEntity o ) { } public void fixRelationships ( ) { } }

Fix:
return ( ( m_parent ) == null ) || ( ( m_entPhysicalContainedIn ) == 0 ) ;