---
title: "Collection has neither generic type or OneToMany.targetEntity() defined:"
author: "east_java"
date: "2009-12-27T01:13:18Z"
tags: []
categories: ["企业架构"]
slug: "collection-has-neither-generic-type-or-onetomany-targetentity-defined"
draft: false
lastmod: "2009-12-27T01:13:18Z"
id: 557662
url: "https://japi.iteye.com/blog/557662"
---

如出现类似以下异常：

org.hibernate.AnnotationException: Collection has neither generic type or OneToMany.targetEntity() defined: org.svse.org.model.Order.orderItems

请检查orderItems这个属性是否使用了泛型,如:Set&lt;OrderItem&gt;.

如果未使用泛型,请在OneToMany注释中使用targetEntity指定元素的类型