草庐IT

CollectionTable

全部标签

java - 如何对 ElementCollection 和 CollectionTable 使用 CriteriaQuery

我有一个非常简单的实体产品,它有代码、名称和标签。标签存储在另一个表(product_tag)中,其中包含product_id和tag列。我需要使用CriteriaQuery搜索带有特定标签的产品。举个例子,我想找到带有“水果”和“红色”标签的产品。使用spring4.1.x、spring-data-jpa1.8和hibernate4.2.x。我的实体只是;@Entity@Table(name="product",uniqueConstraints={@UniqueConstraint(columnNames="code")})@NamedQueries({@NamedQuery(na

java - 一对多映射中的@ElementCollection @CollectionTable

我正在尝试使用嵌入式注释在JPA中建立关系,但我无法成功运行它,这里我的数据库sql脚本如下,createtableTBL_COLLEGE(idintegerprimarykeygeneratedalwaysasidentity(startwith1000,incrementby5),namevarchar(50))createtableTBL_COURSE(Idintegerprimarykeygeneratedalwaysasidentity(startwith10,incrementby1),college_IdintegerreferencesTBL_COLLEGE,namev