由于历史原因,我的数据库中有一些带有 char(3) 主键的表。例如国家表。
当我找到实体时:
String id = "D ";
Country c = em.find(Country.class, id);
之后我可以看到:
c.getId() --> "D" and not "D "
从数据库中一次又一次地读取实体。由于某种原因,缓存不起作用。我猜在缓存中,id 以“D”而不是“D”的形式存在。
20130423 09:15:14,495 FINEST query Execute query ReadObjectQuery(name="country" referenceClass=Country )
20130423 09:15:14,498 FINEST connection reconnecting to external connection pool
20130423 09:15:14,498 FINE sql SELECT countryID, countryNAME, countryTELCODE, countryTOPLEVELDOMAIN, countryINTTELPREFIX FROM geo.COUNTRY WHERE (countryID = ?)
bind => [D ]
20130423 09:15:14,508 FINEST query Execute query ReadObjectQuery(name="country" referenceClass=Country )
20130423 09:15:14,508 FINEST connection reconnecting to external connection pool
20130423 09:15:14,508 FINE sql SELECT countryID, countryNAME, countryTELCODE, countryTOPLEVELDOMAIN, countryINTTELPREFIX FROM geo.COUNTRY WHERE (countryID = ?)
bind => [D ]
我试图设置 @Column(length=3) 但它没有效果。
有没有人知道为什么缓存不能正常工作。
谢谢哈桑