我是Java EE(和Netbeans)的新手。我试图从我的mysql数据库中自动生成实体类...对于简单的关系,它可以工作,但对于以下情况,它总是失败:
我收到以下错误:
内部异常:异常[EclipseLink-7220](Eclipse Persistence Services - 2.3.2.v20111125-r10461):org.eclipse.persistence.exceptions.ValidationException 异常描述:来自实体类[class entities.restaurant.TblContents]的带注释元素[field tblExpandituresTranx]上的@JoinColumns不完整。当源实体类使用复合主键时,必须使用@JoinColumns为每个连接列指定@JoinColumn。必须在每个@JoinColumn中指定name和referencedColumnName元素。有关更多详细信息,请参阅server.log。
我认为......我的数据库中有一些错误,或者EclipseLink JPA工具可能就是kaput! 请帮忙!
答案 0 :(得分:1)
可能是您的架构颠倒了。
或者你实际上可以阅读你得到的异常,并弄清楚它告诉你的是什么:
The @JoinColumns on the annotated element [field tblExpandituresTranx] from the entity class [class entities.restaurant.TblContents] is incomplete. When the source entity class uses a composite primary key, a @JoinColumn must be specified for each join column using the @JoinColumns. Both the name and the referencedColumnName elements must be specified in each such @JoinColumn
看起来你的JOIN规格不完整。
答案 1 :(得分:1)