7

我可以知道Eclipse插件Hibernate工具可以用来生成JPA实体@entity吗?生成的 Java 文件如下所示,而不是 JPA:

package com.test.only.model;    

// Generated Jul 19, 2011 12:13:40 PM by Hibernate Tools 3.2.0.CR1

import java.math.BigDecimal;
import java.util.Date;

/**
 * Account generated by hbm2java
 */
public class Account implements java.io.Serializable {
4

4 回答 4

11

You just need to choose EJB3 + Java5 as configuration options when generating.
Learn more: http://docs.jboss.org/tools/4.0.0.Final/en/hibernatetools/html_single/index.html#jpa_annotations

于 2011-07-23T14:34:13.193 回答
2
于 2011-07-19T06:46:03.760 回答
1

Yes, it can.

Hibernate Tools, which is now available as a part of JBoss Tools, can be used for generating JPA entities as well. In fact you need to select JPA option in Hibernate Configuration which is being used for your project.

Even better would be to start off your reverse code generation as a JPA Project. Then once the project is created switch over to the Hibernate Perspective to confirm the JPA annotations option is selected in the Hibernate Configuration settings.

Following tutorial has pictorial representation of various steps involved in creating a JPA Project in Eclipse. It then shows in the Appendix section how to edit the Hibernate Configuration as well.

http://www.javabrahman.com/j2ee/how-to-setup-a-jpa-project-with-a-data-connection-for-mysql-in-eclipse/

于 2014-02-01T14:52:07.577 回答
1

For me changing from hibernate version 5.4 to 5.2 worked while configuring. and do check use Java5 syntax and Generate EJB3 annotations while code generation.

于 2019-04-08T06:10:02.680 回答