1
이 엔티티가 있으며 동일한 속성 세트가있는 엔티티를 찾고 싶습니다. 나는 여분의 재산 당에 가입하고있는 중이 야오라클의 일치하는지도 열 (MapKeyColumn)을 기준으로 검색 할 수 없습니다.
public List<PropertyResource> findDuplicateProperties(PropertyResource resource) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<PropertyResource> query = builder.createQuery(PropertyResource.class);
Root<PropertyResource> resourceRoot = query.from(PropertyResource.class);
List<Predicate> clauses = Lists.newArrayList();
for (Entry<String, String> entry : resource.getProperties().entrySet()) {
MapJoin<PropertyResource, String, String> properties = resourceRoot.joinMap("properties", JoinType.INNER);
clauses.add(builder.and(builder.equal(properties.key(), entry.getKey()), builder.equal(properties.value(), entry.getValue())));
}
if (!resource.isNew()) {
clauses.add(builder.notEqual(resourceRoot.get("id"), resource.getID()));
}
clauses.add(builder.equal(resourceRoot.get("type"), resource.getType()));
return em.createQuery(query.where(clauses.toArray(new Predicate[clauses.size()]))).getResultList();
}
:
@Entity
public class PropertyResource {
@ElementCollection
@MapKeyColumn(name = "property_key")
@Column(name = "property_value")
@CollectionTable(name = "resource_properties")
private Map<String, String> properties = Maps.newHashMap();
...
}
는이 기준 빌더를 사용하여 내 구현입니다. 같은 유형의 속성 및 리소스가 많지 않은 경우 동일한 속성 키를 사용합니다. 내 질문에 아무 잘못이
select ...
from resource_table propertyre0_
where propertyre0_.entid<>230 and propertyre0_.resource_type=?
있습니까 : 그러나 나는이 얻을 Oracle의
select ...
from resource_table propertyre0_
inner join resource_properties properties1_ on propertyre0_.entid=properties1_.PropertyResource_entid
inner join resource_properties properties2_ on propertyre0_.entid=properties2_.PropertyResource_entid
where properties1_.property_key=? and properties1_.property_value=?
and properties2_.property_key=? and properties2_.property_value=?
and propertyre0_.entid<>4 and propertyre0_.resource_type=?
: 이것은이 생산 H2에 좋은 작품?
OBS : 거의 잊어 버렸습니다. 최대 절전 모드 버전은 4.1.9입니다. 최종.