我正在使用一个非常旧的数据库,我将检索一些特定的数据。 我使用sql server和hibernate。我写了一个名为Language的类,带有一个guid(一个人的id)和一组已知的语言。我将检索数据库中每个人已知的所有语言,但我不知道是否可以使用特定的本机查询来填充语言集。
@NamedNativeQuery(
name = "queryLanguages",
query = "SELECT c.GUIDPersona as guid, d.Caption as language" +
" FROM " +
" Competenze c " +
" INNER JOIN " +
" DomainItemsCaption d " +
" ON (c.IdConoscenza = d.ItemID) " +
" WHERE " +
" d.DomainName = 'Conoscenza' AND " +
" d.Caption LIKE 'Lingue ~ %'",
resultSetMapping = "Languages"
)
@SqlResultSetMapping(
name = "Languages",
entities = {
@EntityResult(
entityClass = Language.class,
fields = {
@FieldResult(name="guid", column="guid"),
@FieldResult(name="languages", column="language")
}
)
}
)
public class Language {
private String guid;
private Set<String> languages;
...
}
我可以使用特定的本机查询填写“语言”字段,检索与该实体关联的人员的所有已知语言吗?