Closed gorbunkov closed 5 years ago
Create two entities with String ID, e.g. Firm and City
@NamePattern("%s|name") @Table(name = "SAMPLE_FIRM") @Entity(name = "sample_Firm") public class Firm extends BaseStringIdEntity implements HasUuid { @Id @Column(name = "CODE", nullable = false, length = 10) protected String code; @Column(name = "NAME") protected String name; @Column(name = "ADDRESS") protected String address; @Column(name = "UUID") protected UUID uuid; //getters and setters }
@NamePattern("%s|name") @Table(name = "SAMPLE_CITY") @Entity(name = "sample_City") public class City extends BaseStringIdEntity implements HasUuid { private static final long serialVersionUID = -7090507348534615303L; @Id @Column(name = "CODE", nullable = false, length = 10) protected String code; @Column(name = "NAME") protected String name; @Column(name = "UUID") protected UUID uuid; //getters and setters }
fts.xml
code
001
This happens because of the following code in the LuceneIndexerBean.indexEntity:
LuceneIndexerBean.indexEntity
if (FtsChangeType.UPDATE.equals(changeType)) { writer.updateDocument(new Term(FLD_ID, entityId.toString()), doc);
The code doesn't take into account that there may be entities with the same id but with the different type in the FTS index.
Sample project: fts-update-bug.zip
P.S. The same error happens on entity deletion. If you remove the Firm with a code 001, the city with this code will be removed from the FTS index as well.
Create two entities with String ID, e.g. Firm and City
fts.xml
config.code
, e.g. 001.001
- you'll get two records: one city and one firm.001
ER: two records will be found AR: only one record is foundThis happens because of the following code in the
LuceneIndexerBean.indexEntity
:The code doesn't take into account that there may be entities with the same id but with the different type in the FTS index.
Sample project: fts-update-bug.zip
P.S. The same error happens on entity deletion. If you remove the Firm with a code
001
, the city with this code will be removed from the FTS index as well.