Код: Выделить всё
@Entity
@Table(name = "XYZ")
@NoArgsConstructor
@AllArgsConstructor
@NamedNativeQueries({
@NamedNativeQuery(
name = [...],
query = " SELECT DISTINCT uuid [...]"
)
})
public class XyzEntity implements Serializable {
@Id
@GeneratedValue(generator = "uuid2")
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Type(type = "uuid-binary")
@Column(name = "uuid", columnDefinition = "RAW(32)", nullable = false)
private UUID uuid;
}
Код: Выделить всё
public List getXyz() {
final Query query = getEntityManager().createNamedQuery([...]);
final List resultList = query.getResultList();
return resultList;
}
Вызов выглядит следующим образом:
Код: Выделить всё
public void abc() {
final List uuids = service.getXyz();
//the start of the loop causes java.lang.ClassCastException: [B cannot be cast to java.util.UUID
for (UUID uuid : uuids) {
//do something
}
}
Подробнее здесь: https://stackoverflow.com/questions/681 ... -util-uuid